Help with MySQL Query?

Posted by Devyn on Stack Overflow See other posts from Stack Overflow or by Devyn
Published on 2010-04-24T22:52:45Z Indexed on 2010/04/24 23:03 UTC
Read the original article Hit count: 157

Filed under:
|
|

I have two tables rooms and users. I want to get only rooms.room_id, users.user_name with user_id = 1. I can get the result of all users with following sql...

select rooms.room_id,
       rooms.user_id,
       users.user_name 
  from rooms 
LEFT JOIN users ON rooms.user_id = users.user_id

When I do like this to filter the result with user_id = 1 ... I got error.

select rooms.room_id,
       rooms.user_id,
       users.user_name 
  from rooms where rooms.user_id = 1 
LEFT JOIN users ON rooms.user_id = users.user_id

What should I do?

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql