我有一个像这样的数据库结构
Car
- id
- carname
- image
- category
- status
Parts
- partid
- partname
CarParts
- carpartid
- carid(fk)
- partid(fk)
- amountid(fk)
Category
- id
- categoryname
Amount
- amountid
- amountvalue
这是我的疑问:
SELECT group_concat(parts.partname) as parts FROM car left join carparts on car.id = carparts.carpartid
left join parts on parts.partid = carparts.carpartid
left join amount on amount.amountid = carparts.amountid where status = 1
group by car.id
但这只显示部分而我想要的其他内容
答案 0 :(得分:0)
您只需要在select中传递列名,请参阅下面的示例:
SELECT
group_concat(parts.partname) as parts,
car.carname,
car.image,
car.category,
car.status
FROM car
left join carparts on car.id = carparts.carpartid
left join parts on parts.partid = carparts.carpartid
left join amount on amount.amountid = carparts.amountid where status = 1
group by car.id