phpbeginner Posted July 17, 2007 Share Posted July 17, 2007 I have a table (tblName) with 6 fields. Now I am using this code to get my data .... $rs=mysql_query("select * from tblName WHERE status='Main'"); Now, I have only one record in my table where status='Main' but I am trying to do another recordset where I get fldDate where status='Main' and get all records that = the same fldDate as the above code. I hope that is explained well and appreciate any help. Link to comment https://forums.phpfreaks.com/topic/60387-a-bit-of-help-with-recordsets/ Share on other sites More sharing options...
akitchin Posted July 17, 2007 Share Posted July 17, 2007 assuming i've understood your question correctly (which is a dangerous assumption, because it wasn't totally clear), you want to pull the fldDate from tblName where the status='Main', and use that fldDate in another query? $resource = mysql_query("SELECT fldDate FROM tblName WHERE status='Main'"); $fldDate = mysql_resul($resource, 0, 0); $new_resource = mysql_query("SELECT * FROM tblName WHERE fldDate='$fldDate'"); alternatively you could concatenate this into one query that contains a subquery, assuming you've got a compatible MySQL version: $resource = mysql_query("SELECT * FROM tblName WHERE fldDate=(SELECT fldDate FROM tblName WHERE status='Main' LIMIT 1)"); Link to comment https://forums.phpfreaks.com/topic/60387-a-bit-of-help-with-recordsets/#findComment-300416 Share on other sites More sharing options...
phpbeginner Posted July 17, 2007 Author Share Posted July 17, 2007 Your assumption is exactly correct in what I am trying to do. Thanks so Much ! Link to comment https://forums.phpfreaks.com/topic/60387-a-bit-of-help-with-recordsets/#findComment-300418 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.