UNKNOWN //************************************** // Name: sub select for mySQL // Description:how to do subselects in mySQL // By: the_firm // // // Inputs:None // // Returns:None // //Assumes:None // //Side Effects:None //This code is copyrighted and has limited warranties. //Please see http://www.Planet-Source-Code.com/xq/ASP/txtCodeId.629/lngWId.8/qx/vb/scripts/ShowCode.htm //for details. //************************************** $query = "CREATE TABLE tmp SELECT my_id FROM table1 WHERE myvalue is null "; mysql_query ($query); $query = "SELECT sec_id, info FROM table2 LEFT JOIN tmp ON sec_id = my_id WHERE sec_id NOT IN(my_id) "; $result=mysql_query ($query); mysql_query ("DROP TABLE tmp"); while ($row = mysql_fetch_array ($result)) { echo $row["sec_id"]."\n"; echo $row["info"]."\n"; }