我知道我們有了一個方法可以做到這一點,但我的生活,我不能弄明白:MySQL的加入多對多單排
我有3代表我想加入一起(簡體說明):
users
uid mail
1 [email protected]
2 [email protected]
3 [email protected]
profile_fields
fid name label
1 full_name Full Name
2 phone Phone
profile_values
uid fid value
1 1 Q Q
1 2 5555555555
2 1 Ww Ww
3 2 4444525411
我想獲取表單的結果:
uid mail full_name phone
1 [email protected] Q Q 5555555555
2 [email protected] Ww Ww NULL
3 [email protected] NULL 44445454111
我已經試過各種選擇具有不同的連接條件,但我似乎無法弄清楚如何獲得profile_fields的行我的列在我的選擇
編輯:我也嘗試了谷歌搜索周圍,但我似乎無法弄清楚如何將這句話谷歌。
已更新 - 缺少的行可能是因爲我加入了「PROFILE_VALUES」表,而不是「PROFILE_VALUES」表中沒有記錄的用戶的LEFT JOINing。 – 2010-01-06 16:38:15
我試過把它作爲一個左連接,仍然只是在行上。我會看看使用Views Bonus Pack來製作至少這個報告。 – 2010-01-06 16:51:44