RE: [PHP] How do I make these two MySQL queries into one line? [SOLVED]

2003-12-24 Thread Dave G
Chris,
Thank you! I will look on the net for "left joins", which is a
bit new to me, and I'll join a MySQL list, since I can see I'm going to
have more MySQL questions in the future.
Your reply is much appreciated, especially since it came so
fast!

-- 
Yoroshiku!
Dave G
[EMAIL PROTECTED]

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



RE: [PHP] How do I make these two MySQL queries into one line?

2003-12-24 Thread Chris
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



[PHP] How do I make these two MySQL queries into one line?

2003-12-23 Thread Dave G
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