Hey everyone,
I am looking to write a query that I think can be solved a nested select but I am not yet that fluent in MySQL to be able to get the query working correctly.
Basically what I want to do is this;
SELECT count(*) from Inquiry
Inner Join Inquirer on Inquirer.ID = Inquiry.InquirerID_fk
WHERE Inquirer.Program = 'value' AND Inquiry.ID
does not exist in (SELECT TransferInquiryID_fk from Transfer)
as you can see I want all results where the Inquiry.ID of the record is not contained in the list of TransferInquiryID's
If anyone could help me out with this that would be great.
Thank you very much,
NickG
nickg21
0
Newbie Poster
Recommended Answers
Jump to PostYou might also consider left-joining to transfer. It tends to perform better:
SELECT count(*) from Inquiry Inner Join Inquirer on Inquirer.ID = Inquiry.InquirerID_fk left join Transfer on Inquiry.ID = Transfer.TransferInquiryId_fk WHERE Inquirer.Program = 'value' AND TransferInquiryID_fk IS NULL
Generally speaking, your query has to resolve the …
All 3 Replies
nickg21
0
Newbie Poster
simplypixie
123
Posting Pro in Training
BitBlt
452
Practically a Master Poster
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.