Reputation: 1281
I have 3 tables, a,b,c
It is possible to add left join for two table select add 3rd table by left join:
example:
SELECT * from a,b where a.x=b.x and a.z=b.z and b.y>0
(there I need select only that records where I can found exact matches by that rules)
now I want add some fields from 3rd table, but there are possible situation that 3rd table may not contain data for some table a,b records. As I understand I can use left join ?
I How can select something this:
SELECT a.*,b.*, c.Q from a,b where a.x=b.x and a.z=b.z and b.y>0 left join c on a.x=c.x
Upvotes: 0
Views: 2249
Reputation: 4354
SELECT a.*,b.*, c.Q
FROM a
INNER JOIN b
ON a.x=b.x AND a.z=b.z AND b.y>0
LEFT JOIN c
ON a.x=c.x
Upvotes: 1
Reputation: 11054
If you don't like writing INNER JOINs:
SELECT a.*,b.*, c.Q
FROM (a,b)
LEFT JOIN c
ON a.x=c.x
WHERE a.x=b.x and a.z=b.z and b.y>0
Upvotes: 2