RE: [PHP] How do I make these two MySQL queries into one line?
| From: | Chris | Date: | Wed, 24 Dec 2003 07:04:22 +0000 |
| Subject: | RE: [PHP] How do I make these two MySQL queries into one line? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173290@lists.php.net to get a copy of this message | ||
You should *really* consider yourself lucky, because this is a PHP list, not
MySQL.
"SELECT members.email FROM groups LEFT JOIN members USING(member_id) WHERE
'$chosenGroup'=group_id AND 'yes'=active"
You should really find a tutorial on Joins, jsut search on `SQL tutorial
joins`
Chris
-----Original Message-----
From: Dave G [mailto:ml@autotelic.com]
Sent: Tuesday, December 23, 2003 10:45 PM
To: 'PHP General'
Subject: [PHP] How do I make these two MySQL queries into one line?
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
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php