SELECT DISTINCT
t1.name as t1_name,
MAX(t1.unit) as t1_unit,
MAX(t1.id_producer_goods) AS hi_id_producer_goods,
t2.name as t2_name
FROM Table1 t1
left join Table2 t2 on t1.id_web_site=t2.id_web_site
WHERE t1.id='23'
GROUP BY t1.name
当我运行查询时,我收到以下错误:
Column 'Table2.name' is invalid in the select list because it is not contained
in either an aggregate function or the GROUP BY clause.
如何编写这个查询?