Re: Multiple SELECT querys
| From: | Jim Lucas [php] | Date: | Fri, 22 Mar 2002 21:29:08 +0000 |
| Subject: | Re: Multiple SELECT querys | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17849@lists.php.net to get a copy of this message | ||
I will take this example and improve upon it, try this:
$query = "SELECT myvalue FROM mytable WHERE some_condition";
$result = mysql_query($query) or die("Error: ".mysql_error());
$srch = array();
while( list($myvalue) = mysql_fetch_array($result)
{
$srch[] = $myvalue;
}
$query = "SELECT * FROM other_table WHERE this_val IN('". join("',
'",
$srch). "')";
$result = mysql_query($query) or die("Error: ".mysql_error());
----- Original Message -----
From: "Rick Emery" <remery@excel.com>
To: "'Morten Nielsen'" <mosgaard2000@hotmail.com>;
<php-db@lists.php.net>
Sent: Friday, March 22, 2002 12:53 PM
Subject: RE: [PHP-DB] Multiple SELECT querys
> $query = "SELECT myvalue FROM mytable WHERE some_condition";
> $result = mysql_query($query) or die("Error: ".mysql_error());
> $srch = "";
> while( list($myvalue) = mysql_fetch_array($result)
> {
> $srch .= "$myvalue, ";
> }
> $srch = substr($srch, 0, -2);
> $query = "SELECT * FROM other_table WHERE this_val IN($srch)";
> $result = mysql_query($query) or die("Error: ".mysql_error());
>
> -----Original Message-----
> From: Morten Nielsen [mailto:mosgaard2000@hotmail.com]
> Sent: Friday, March 22, 2002 2:28 PM
> To: php-db@lists.php.net
> Subject: [PHP-DB] Multiple SELECT querys
>
>
> Hi,
>
> I make a SELECT in a mySQL database. It returns a variable, which contains
> 10 values. I then need to make another SELECT in a new database where I
have
> to use the previous 10 values in the WHERE sentence. How can I do this?
>
> Regards,
> Morten
>
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>