i have two tables the first one is cont_details
-------------- --------------
| cont_details_id | cont_no |
-----------------------------
| 1 | A001 |
| 2 | A002 |
| 3 | A003 |
------------------------------
and the second one is cont_sold_tmp
--------------
| id | cont_no |
--------------
| 1 | 1 |
| 2 | 3 |
----------------
now i need to select from table cont_details table which are not in temp_cont
so i used this query
select * from cont_details left join cont_sold_tmp on cont_details.cont_details_id = cont_sold_tmp.cont_no where cont_sold_tmp.cont_no is null
This query works perfectly when i check in PhpmyAdmin but when i use it in HTMl, not working
<select name="cont_no" id="cont_no" data-rel="chosen">
<option value="">Select</option>
<?php
$qry = mysql_query("select * from cont_details left join cont_sold_tmp on cont_details.cont_details_id = cont_sold_tmp.cont_no where cont_sold_tmp.cont_no is null");
while($res = mysql_fetch_array($qry))
{
?>
<option value="<?php echo $res["cont_details_id"];?>">
<?php echo $res["cont_no"];?>
</option>
<?php } ?>
</select>
Database connections are working perfectly, instead of join query i just checked with the simple query "select * from cont_details" its shows all the records. but when i use this join query. i dont get any records in dropdown