我有以下表格:users,这些表格是自我解释的,answers,其中载有特定用户特定日期的答复清单。
users
-----
ID FIRST_NAME LAST_NAME
1 Joe Bloggs
2 Fred Sexy
3 Jo Fine
4 Yo Dude
5 Hi There
answers
-------
ID CREATED_AT RESPONSE USER_ID
1 2011-01-01 3 1
2 2011-01-01 4 2
3 2011-01-02 5 5
我的目的是形成一种看法,得出以下结果:
USER_ID CREATED_AT RESPONSE
1 2011-01-01 3
2 2011-01-01 4
3 2011-01-01 NULL
4 2011-01-01 NULL
5 2011-01-01 NULL
1 2011-01-02 NULL
2 2011-01-02 NULL
3 2011-01-02 NULL
4 2011-01-02 NULL
5 2011-01-02 5
I have been trying to do this in one SELECT statement but I don t believe it is possible, maybe I m missing something? I can accomplish the output with multiple statements but I m looking for a more elegant method which can sit in a view (or multiple views).
提前感谢!