你有什麼試過?
一個完整的外連接會爲你做到這一點。您可以模擬一個帶有兩個外部聯接和UNION ALL:
select
e.entry_id, e.entry_date, e.entry_amount, e.user_id,
f.forecast_id, f.forecast_date, f.forecast_amount, f.user_id
from
Entry e
left outer join Forecast f on f.user_id = e.user_id and f.forecast_date = e.entry_date
union all
select
e.entry_id, e.entry_date, e.entry_amount, e.user_id,
f.forecast_id, f.forecast_date, f.forecast_amount, f.user_id
from
Entry e
right outer join Forecast f on f.user_id = e.user_id and f.forecast_date = e.entry_date
where
e.entry_id is null
給出是的,全外部連接不支持在mysql中,直到日期檢查我的答案。 – 2009-09-02 08:18:26