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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.