Thread: Join
View Single Post
Old 02-13-2008, 03:55 AM   #4 (permalink)
SOCK
The Acquainted
 
Join Date: Nov 2007
Posts: 154
Thanks: 31
SOCK is on a distinguished road
Default

So we're assuming the relation between the two tables is members.id ==> info.user_id? You might consider using `member_id` as the column name on both columns, it looks a bit ambiguous. I usually use naming conventions like members.memberID ==> info.memberID_FK to relate the two tables and make it clear the info table stores the Foreign Key.

Code:
SELECT
 m.username
, m.password
, i.info1
, i.info2
FROM members AS m
INNER JOIN info AS i
ON ( m.id = i.user_id )
WHERE m.id = 2;
I'd be happy to provide a 'real' JOIN with the CONCAT expression if you'd provide more detail on the columns and what output you expect.

Please post any questions you have as to the JOIN statement itself.
__________________
I reject your reality, and substitute my own.
SOCK is offline  
Reply With Quote