SELECT Data from multiple tables?

Posted by Kyle R on Stack Overflow See other posts from Stack Overflow or by Kyle R
Published on 2011-02-20T07:16:06Z Indexed on 2011/02/20 7:24 UTC
Read the original article Hit count: 112

Filed under:
|

I have 3 tables, with 3 fields all the same. I basically want to select information from each table

For example:

userid = 1

I want to select data from all 3 tables, where userid = 1

I am currently using:

   SELECT r.*, 
          p.*, 
          l.*
     FROM random r
LEFT JOIN pandom p ON r.userid = p.userid
LEFT JOIN landom l ON l.userid = r.userid
    WHERE r.userid = '1'
    LIMIT 0, 30

But it doesn't seem to work.

© Stack Overflow or respective owner

Related posts about sql

Related posts about mysql