• 2023年5月30日

sql查询使用inner join出现重复数据问题

inner join 的表会把该表符合on条件的数据全部列出来与前面的表、inner join表数据形成多余的数据例如:select * from table1 t1inner join table2 t2 on t2.col1 = t1.col1 and t2.col2=t2.col2where t1. col3=’x’ 结果会出现单独查询 select * from table1 where col3=’x’ 只有1条记录但是因为table2存在100条 t2.col2=t1.col2 and t2.col1=t1.col1 导致上面的inner join语句执行完会出现100条记录

详细内容