select * from temp1 left join temp2 on temp1.id = temp2.id
(select * from temp1 有355条记录)
temp1表和temp2表只有Id一个字段关联,我要获取temp2表中type_name这个字段,
表2中有重复的数据,所以我用left join 联合查询的话,返回的不止355条记录,我要怎样去掉重复的数据,sql语句太长,子查询太多,用distinct性能太低,有没有其他办法?
菜鸟@程序猿的博客如统计数量count、求和sum、最大值max、最小值min SQL执行原理 1、sql语句的完整结构 SELECT …,… (存在聚合函数) FROM … (LEFT/RIGHT/INNER) JOIN …ON WHERE …不包含聚合函数的过滤条件 GROUP BY …,… ...
Inspiration666的博客 -- sql语句 select * from class left join book on class.card=book.card left join phone on book.card=phone.card; explain select * from class left join book on class.card=book.card left join phone on ...