03-16-2009, 05:36 PM
|
#2 (permalink)
|
|
is cute and cuddly
Join Date: Mar 2008
Location: Vegas, Baby
Posts: 963
Thanks: 31
|
You want to look up what's called a 'join', ie; http://www.w3schools.com/Sql/sql_join.asp
PHP Code:
SELECT t1.id, t1.nickname, t2.email FROM table1 AS t1 INNER JOIN table2 AS t2 ON t1.id=t2.id WHERE t1.rights = 3
Broken down:
PHP Code:
SELECT t1.id, t1.nickname, t2.email // Select the id, nickname and email data. We don't need to select the rights, we already know // everybody selected from this query should be equal to 3
FROM table1 AS t1 // The primary table we're operating on
INNER JOIN table2 AS t2 // We use an inner join because we only want to return records where there is at least one // row in both tables that match the join condition.
ON t1.id=t2.id // The join condition
WHERE t1.rights = 3 // Where the rights column of table one is equal to 3
I haven't programmed in nearly 6 months so I could be a little rusty but I'm fairly certain this is what you're in the market for.
|
|
|
|