-
Help with a Query
Hello Team,
I have a set of 3 tables.
Tables A, B, C
Tables A and B are inner joined using an ID field and Tables B and C are left joined using another ID field.
I need all those records from table B irrespective of whether data is there in Table C or not and the other condition is one of the values in table C has to match the value selected from a dropdown.
Basically Query goes like this.
SELECT B.<field1>, B.<field2>, B.<field3>, B.<field4>, B.<field5>, A.<field1>, A.<field2>, A.<field3>, iif(isnull(C.<fieldname>,"N") FROM (B INNER JOIN A ON A.<fieldname> = B.<fieldname) LEFT JOIN C ON B.ID = C.QuestId where C.ClientId=<Some value got at runtime>
Now as long as I dont give the where condition, my output is fine.. When there are no records for the selected client, it gives me 0 rows.
Whether there is record for this particular client or not my out put has to fetch all the rows from table B
Thanking in advance.
Regards,
K. Sripriya
-
Create a query based on table C that does the filtering for the clientID. Do you left join of B to that newly created query.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules