I have table tblConsentQuestion
with Questions
intID nvcText bitActive17 Question1 True18 Question2 True19 Question3 False
and table tblConsentData
with the questions for every customer
intID intCustomerID bitConsent intIDQuestion 14 1 False 1915 1 True 18
WHERE tblConsentQuestion.intID = tblConsentData.intIDQuestion
I would like to retrieve in a VB.net dataset
All
tblConsentData
for a specific Customer ie two records withintID
=14
and15
All active (
bitActive = true
) records intblConsentQuestion
WHERE tblConsentData.intIDQuestion <> tblConsentQuestion.intID, in this case onlyintID
=17
record (in addition to the two records)
Output should be
Question3 FalseQuestion2 TrueQuestion1 Null
I tried something like
str = "Select tblConsentQuestion.intID, bitConsent, nvcText" & fungGetLangId() & " AS nvcqText " _ & " From tblConsentData " _ & " Left OUTER JOIN tblConsentQuestion " _ & " On tblConsentData.intIDQuestion = tblConsentQuestion.intID " _ & " where tblConsentData.intCustomerID = " & intCustomerID & " " _ & " UNION ALL " _ & " Select tblConsentQuestion.intID, -1, nvcText" & fungGetLangId() & " " _ & " From tblConsentQuestion " _ & " Left OUTER JOIN tblConsentData " _ & " On tblConsentData.intIDQuestion = tblConsentQuestion.intID " _ & " WHERE(tblConsentQuestion.bitActive = 'True') "
and I receive All active records in tblConsentQuestion
, whereas I should not receive record with intID
= 18
, which exists in