1 回答

TA貢獻1829條經(jīng)驗 獲得超9個贊
基本上,您需要另一個加入areas_group;要消除對同一個表的兩個引用的歧義,您需要使用表別名。
實際上,對在查詢中起作用的所有表使用表別名是一個很好的做法:這使得查詢更易于讀寫。
SELECT
t.id AS transfer_id,
t.name AS transfer_name,
t.pickup_areas_group_id AS transfer_pickup_areas_group_id,
ag1.area_id AS pickup_area_ids,
t.drop_areas_group_id AS transfer_drop_areas_group_id,
ag2.area_id AS drop_area_ids
tp.vehicle_id AS vehicle_id,
tp.date_start AS date_start,
tp.date_end AS date_end,
tp.price AS price
FROM transfers t
INNER JOIN transfers_pricing tp ON tp.transfer_id = t.id
INNER JOIN areas_group ag1 ON ag1.id = t.pickup_areas_group_id
INNER JOIN areas_group ag2 ON ag2.id = t.drop_areas_group_id
- 1 回答
- 0 關注
- 101 瀏覽
添加回答
舉報