select table1.* from table1 left outer join table2 on table1.callnumber=table2.callnumber
此时,如果table2 中有重复记录 那么这条语句就会取出重复的记录,请问在使用 left outer join 时如何排重重复的记录? 用DISTINCT 不合适,TABLE1的字段太多了,还包含ID!
...全文
954打赏收藏
sql left outer join 排重问题!
select table1.* from table1 left outer join table2 on table1.callnumber=table2.callnumber 此时,如果table2 中有重复记录 那么这条语句就会取出重复的记录,请问在使用 left outer join 时如何排重重复的记录? 用DISTINCT 不合适,TABLE1的字段太多了,还包含ID!
Table1记录太多,可以DISTINCT Table2啊。
select table1.* from table1 left outer join (select distinct callnumber from table2) table2 on table1.callnumber=table2.callnumber