1 回答
TA贡献1829条经验 获得超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 关注
- 83 浏览
添加回答
举报