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:[EMAIL PROTECTED]
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
[EMAIL PROTECTED]

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to