Nested Select Statement MySQL Queryhttp://forums.asp.net/t/1778550.aspx/1?Nested+Select+Statement+MySQL+QueryFri, 09 Mar 2012 18:12:14 -050017785504871912http://forums.asp.net/p/1778550/4871912.aspx/1?Nested+Select+Statement+MySQL+QueryNested Select Statement MySQL Query <p>Hey everyone, I need help creating a nested Select statement in MySQL. &nbsp;Currently I have a query that uses a couple inner joins to return a result set. &nbsp;The query and results are as follows;</p> <pre class="prettyprint">SELECT DISTINCT NoAdmit.InquiryID_fk, Patient.Name, Inquiry.DecisionMade, Inquiry.Date, Inquirer.Name, Inquirer.Program from Patient INNER JOIN (Inquiry INNER JOIN NoAdmit on NoAdmit.InquiryID_fk = Inquiry.ID Inner Join Inquirer on Inquirer.ID = Inquiry.InquirerID_fk) on Inquiry.PatientID_fk = Patient.ID</pre> <pre class="prettyprint">InquiryID_FK Name DecisionMade Date Name Program</pre> <pre class="prettyprint">1 Nick Do Not Admit 1/2/2012 John Doe Program1</pre> <p>Since this query is used in an SQLDataSource I would like to append to it to also include this query;</p> <p>SELECT * from DecAdmit Where DecAdmit.ActualAdmitDate &gt; GetDate()<br> Basically saying, that if the ActualAdmitDate field has a date value that is later than todays date that include that in the resultset. I am just unable how to add this as a nested Select statement or another Join.</p> <p>The join could be used on Inquiry.ID = DecAdmit.InquiryID_fk</p> <p>Any help would be appreciated.</p> <p>Thank you,</p> <p>Nick</p> 2012-03-09T14:35:56-05:004872203http://forums.asp.net/p/1778550/4872203.aspx/1?Re+Nested+Select+Statement+MySQL+QueryRe: Nested Select Statement MySQL Query <pre class="prettyprint">SELECT DISTINCT NoAdmit.InquiryID_fk, Patient.Name, Inquiry.DecisionMade, Inquiry.Date, Inquirer.Name, Inquirer.Program FROM Patient INNER JOIN Inquiry ON Inquiry.PatientID_fk = Patient.ID INNER JOIN NoAdmit ON NoAdmit.InquiryID_fk = Inquiry.ID INNER JOIN Inquirer ON Inquirer.ID = Inquiry.InquirerID_fk) /</pre> 2012-03-09T18:12:14-05:00