mysql - SQL still got duplicate rows after add DISTINCT -
here sql include 3 tables,trans,sys_org , sys_pay.select through mid (but not unique)
i tried
select distinct trans.mid,trans.a,sys_org.b,sys_org.c,sys_pay.d sys_org left join trans on sys_org.mid = trans.mid left join sys_pay on sys_org.mid = sys_pay.mid
and returns duplicate rows,how fix it?
return this:
trans.mid trans.a sys_org.b sys_org.c sys_pay.d 1111 aaa bbb ccc ddd 1111 aaa bbb ccc ddd
i sure rows distinct here distinct means whole row not specific column.
if not create sqlfiddle can check it.
further if want fetch unique value based on specific field should use group by.
Comments
Post a Comment