Join me on INNER JOIN!
Posted: Sat Feb 25, 2006 8:14 am
Hi,
I'm having some problems with a SQL query. The thing is that I need to join a table "users" with two tables...which means that it won't be unique because user_name will occur more than once....how can I avoid this problem. I would like to retriev the data using only one query if it's possible. I have put the incorrect syntax in brackets...but left it in to show what I need to do.
Cheers
Mikael
I'm having some problems with a SQL query. The thing is that I need to join a table "users" with two tables...which means that it won't be unique because user_name will occur more than once....how can I avoid this problem. I would like to retriev the data using only one query if it's possible. I have put the incorrect syntax in brackets...but left it in to show what I need to do.
Code: Select all
SELECT users.user_name, spotlight.message, reply.message
FROM spotlight INNER JOIN reply ON spotlight.id = reply.s_id
INNER JOIN users ON users.id = reply.user_id
(INNER JOIN users ON spotlight.user_id = users.id)
WHERE spotlight.id=1Cheers
Mikael