How do I make these two MySQL queries into one line?
| From: | Dave G | Date: | Wed, 24 Dec 2003 06:45:29 +0000 |
| Subject: | How do I make these two MySQL queries into one line? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-173289@lists.php.net to get a copy of this message | ||
PHP Gurus,
I'll consider myself lucky to get a response so close to
Christmas, but here goes.
I have two tables. One contains member information, and one
lists which groups the members belong to. I want to select the email
address of active members from the member information table, and I want
to select only the members which belong to a particular group. Right now
I can only think to accomplish this in two lines:
$query1 = "SELECT member_id FROM groups WHERE group_id =" .
$chosenGroup
Then, take the results and do another query:
$query2 = "SELECT email FROM members WHERE active = yes AND
member_id =" . $query1Results
But surely there's a way to collapse this into one MySQL line.
--
Yoroshiku!
Dave G
ml@autotelic.com