1
我有以下查詢:加入到餐桌多FKS和行
SELECT p.id,
p.firstname,
**p.address1id,
p.address2id,**
r.invoice_id,
i.authcode
FROM membershiprenewals r,
Profile p,
Invoice i
WHERE r.orgID = 1
and r.period_id = 3
and r.status = 0
and r.profile_id = p.id
and r.invoice_id = i.id;
此表中選擇一個用戶配置文件和一些相關的細節。
配置文件地址存儲在另一個表(配置文件地址)中。一個配置文件可以有2個地址。這些地址使用p.address1和p.address2引用。
我需要擴展此查詢以加入profileaddress表,以獲得兩個地址並組合到單個記錄中。
所以我需要的結果會是以下幾列
p.id | p.firstname | .. etc .. | profileaddress1.address | profileaddress1.town | profileaddress2.address | profileaddress2.town | .. etc
我一直在玩弄JOIN聲明幾個小時,但似乎就是無法破解它。
任何幫助極大讚賞!
傑森
戈登..我放下你的查詢,它只是跑了。正是我需要的。謝謝 !!!我可以問爲什麼顯式加入逗號?再次感謝! – Jason