Jump to content

A bit of help with recordsets


phpbeginner

Recommended Posts

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

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)");

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.