Subject | Re: [firebird-support] join question |
---|---|
Author | Svein Erling Tysvær |
Post date | 2017-04-11T11:23:05Z |
Simple, just make sure you only refer to table b in the left join and not in the where clause:
Select a.nrworker, b.valueworkermonth from table A left join table B on a.nrworker = b.nrworker and a.active = 1 and b.year = 2017 and b.month = 4
HTH,
Set
2017-04-11 12:14 GMT+02:00 'Check_Mail' check_mail@... [firebird-support] <firebird-support@yahoogroups.com>:
Hello @ll,
I have a small question.
Table A
NrWorker ineger
Name
Active 0 or 1
…
Table B
NrWorker integer
Year
Month
ValueWorkerMonth
Now I would like to get all NrWorker from Table A with Active 1 and the ValueWorkerMonth from the Table B (from the current month)
This is like
Select a.nrworker, b.valueworkermonth from table A left join table B on a.nrworker = b.nrworker where a.active = 1 and b.year = 2017 and b.month = 4
Fine, but I would like also all Worker (NrWorker from Table A) where are not present in Table B in this month.
Table A
NrWorker 12
NrWorker 13
NrWorker 14
Table B
NrWorker 12
Year 2017
Month 4
I would like to get not only Worker 12, rather 13 and 14 too.
How can I realize it in Firebird?
Thank you