Subject | Re: [firebird-support] Left join derived table |
---|---|
Author | liviuslivius |
Post date | 2016-09-28T10:39:26Z |
W dniu 2016-09-28 09:04:07 użytkownik 'Marcin Bury' marcin.bury@... [firebird-support] <firebird-support@yahoogroups.com> napisał:
Hello All
I'd like to ask how to get below statement working:
SELECT A.FIELD_1, A.FIELD_2, D.FIELD_D1, D.FIELD_D2
FROM TABLE_A A
LEFT JOIN (SELECT FIRST 1 FIELD_D1, FIELD_D2 FROM TABLE_D D WHERE
D.FIELD_3 = A.FIELD_3 ORDER BY D.ID DESC) D ON (1=1)
Firebird complains that A.FIELD_3: Column does not belong to referenced
table.
I have the 'one to many' relation between TABLE_A and TABLE_D, and I
would like to join a record from TABLE_A with latest detail entry from
TABLE_D.
Maybe derived tables are not the right solution here.
Thanks
Marcin
__._,_.___._,___Hi,SELECT A.FIELD_1, A.FIELD_2, D.FIELD_D1, D.FIELD_D2
FROM TABLE_A A
LEFT JOIN (SELECT FIRST 1 D.FIELD_D1, D.FIELD_D2, D.FIELD_3 FROM TABLE_D DORDER BY D.ID DESC) D ON D.FIELD_3 = A.FIELD_3regards,Karol Bieniaszewski