none
Multiple join with multiple conditions RRS feed

  • Question

  • I need to retrieve data's on joining few tables.My issue is retrieval  based on a table column that varies.I need to get a username list from users table by  joining another share table in case the share table has no rows or if it has rows with status = 3 or 4 but not 1 or 2.In short get all the username list of a class if share table has empty rows and suppose if it has rows with status 3 or 4 or 1 or 2 get only the username with status 3 or 4 but not 1 and 2.

    I've tried the below code but still shows all the username even when the status is 1 or 2.


    select aspnet_users.username,aspnet_users.UserId,lc.LearningCartsDatabaseId from aspnet_users 
    join EnrollmentEntry ee on aspnet_Users.UserId  = ee.UserId 
    join EnrollmentEntriesInLearningCarts eel on ee.EnrollmentEntryDatabaseID = eel.EnrollmentEntryDatabaseID
    join LearningCarts lc on lc.LearningCartsDatabaseId = eel.LearningCartsDatabaseId 
    left outer join ILCSharedResources ilsh on ilsh.OriginatorLearningCartsDatabaseId = 'E70047EB-9D61-E211-9CE1-000C296C02CA'
    
     
    where ee.TutorialDatabaseID ='5894345C-661C-E211-9CE1-000C296C02CA' 
     and aspnet_Users.UserId != 'FF3DF6A1-2152-49EE-82EC-2BA3416344C8' 
      
    or (ilsh.Status = 3 or ilsh.Status = 4)


    Friday, June 7, 2013 4:07 PM

Answers

  • I,

    I'm afraid you won't be helped here. This forum deals with developments pertaining to the Microsoft Project range of products. I'm convinced there must be forums specializing in SQL!

    Greetings,

    Friday, June 7, 2013 7:20 PM
    Moderator

All replies

  • I,

    I'm afraid you won't be helped here. This forum deals with developments pertaining to the Microsoft Project range of products. I'm convinced there must be forums specializing in SQL!

    Greetings,

    Friday, June 7, 2013 7:20 PM
    Moderator
  • Hi,

    or (ilsh.Status = 3 or ilsh.Status = 4)

    // in above code replace your starting "or" with "and"

    Thanks,

    Rohit

    Monday, June 17, 2013 4:50 AM