[GENERAL] left outer join without rows from left table

2009-02-16 Thread Scara Maccai
Hi all, I want to get data from these tables: TABID integer id, name varchar example values: 1 'id1' 2 'id2' [...] TABA integer id, timestamp t, integer a example values: 1 '2009-02-13 00:00:00' 10 1 '2009-02-13 02:00:00' 19 TABB integer id, timestamp t, integer b example values: 1 '2009-02-13

Re: [GENERAL] left outer join without rows from left table

2009-02-16 Thread Sam Mason
On Mon, Feb 16, 2009 at 12:15:47AM -0800, Scara Maccai wrote: select * from TABID left outer join TABA on (id) left outer join TABB on TABB.id = TABID.id and TABA.t = TABB.t So, basically, all the rows from table TABID joined with both table TABA and TABB. The problem is that some times TABB

Re: [GENERAL] left outer join without rows from left table

2009-02-16 Thread Scara Maccai
Thank you: that's exactly what I needed. I think you want to use a full outer join with slightly unusual bracketing: SELECT t.id, COALESCE(a.t,b.t) AS t, a.a, b.b FROM tabid t LEFT JOIN ( taba a FULL OUTER JOIN tabb b ON (a.id,a.t) = (b.id,b.t)) ON t.id =