Note that there are some explanatory texts on larger screens.

plurals
  1. POGet all records from master table and matching from child using WHERE mysql query
    text
    copied!<p>I have two table in my MySQL table: <br> <code>1) mast_checkup (master)</code> <br> <code>2) tbl_lab_checkup (child)</code></p> <p>Table structure is as follow: <br> <code>1) mast_checkup:</code></p> <p>-- checkid (pk) <br> -- title <br> -- description <br></p> <p><code>2) tbl_lab_checkup</code></p> <p>-- labcheckupid(pk) <br> -- labid(fk) <br> -- mastcheckupid(fk) <br> -- discount <br> -- cost <br></p> <p>I want to show all the records from master table and all records from child table where labid='1 I tried following query.</p> <pre><code>SELECT * FROM mast_checkup mc LEFT JOIN tbl_lab_checkup tlc ON mc.checkupid=tlc.mastcheckupid WHERE tlc.ladid=1 </code></pre> <p>Couldn't get exact result. </p> <p><strong>What I need is all records from patent table and matching from child and if no match found from child it should result all master fields and null child fields</strong></p> <p>Required Result</p> <pre><code>---------------------------------------------------------------------------------------- checkid | title | labcheckupid| labid | discount | cost ---------------------------------------------------------------------------------------- 1 |title 1 | 1 |1 | 5 | 1500 2 |title 2 | NULL |NULL |NULL | NULL ---------------------------------------------------------------------------------------- </code></pre> <p>first is a records which is in both master and child table and second one is only in master but not in child</p> <p>Any solutions for this requirement ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload