我收到此错误:
Mysql2::Error: Unknown column 's.supplier' in 'field list': SELECT s.id, s.supplier, s.vendor, s.title, s.edition, CAST(SUM(l.amount) as UNSIGNED) AS amount
FROM softwares s
LEFT JOIN licenses l ON s.id=l.software_id
GROUP BY s.supplier, s.vendor, s.title, s.edition
然而供应商是软件表中的一列,所以我不确定它为什么不认识它?
答案 0 :(得分:1)
s.supplier_id
,它应该是。您使用了错误的列名称。
答案 1 :(得分:0)
使用supplier_id
代替supplier
您的查询应该类似于
SELECT s.id, s.supplier_id, s.vendor, s.title, s.edition, CAST(SUM(l.amount) as UNSIGNED) AS amount
FROM softwares s
LEFT JOIN licenses l ON s.id=l.software_id
GROUP BY s.supplier_id, s.vendor, s.title, s.edition