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
Jump to Post
You 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
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.