mysql - joining three tables with HAVING

Posted by Qiao on Stack Overflow See other posts from Stack Overflow or by Qiao
Published on 2010-03-24T21:50:08Z Indexed on 2010/03/24 21:53 UTC
Read the original article Hit count: 303

Filed under:

I have table:

id name type

where "type" is 1 or 2

I need to join this table with two other. Rows with "type = 1" should be joined with first table, and =2 with second.

Something like

SELECT *
FROM tbl
INNER JOIN tbl_1 ON tbl.name = tbl_1.name HAVING tbl.type = 1
INNER JOIN tbl_2 ON tbl.name = tbl_2.name HAVING tbl.type = 2

But it does not working.
How it can be implemented?

© Stack Overflow or respective owner

Related posts about mysql