这是我的查询
select * from table1 inner join table2 on table1.typeId=table2.typeId;
如果 table2 中的 typeId 不重复多次,则此方法可以正常工作,但如果 typeId 多次存在,则会给出重复的行。 有什么办法可以避免重复行吗?
table1 -- Name typeId
Jay 1
roy 2
table2 -- Type typeId
L 1
M 1
N 2
K 2
Expected output Jay 1
Output getting is Jay 1
Jay 1
最佳答案
select DISTINCT table1.Name, table2.typeId
from table1 inner join table2 on table1.typeId=table2.typeId;
关于mysql - 如何在mysql中进行内连接查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9928340/