有人能帮帮我吗?内连接查询工作正常。但查询显示重复数据。我不显示重复数据。 这是我的询问。
SELECT DISTINCT t1.class, t1.classid, t2.classid, t2.option_name
FROM table1 AS t1
INNER JOIN table AS t2 ON t1.classid = t2.classid
这是输出
"COLOR";"456";"456";"Nude"
"COLOR";"456";"456";"Ivory"
"COLOR";"456";"456";"Black"
"COLOR";"456";"456";"Coral"
"COLOR";"459";"459";"Black"
"COLOR";"459";"459";"Coral"
"COLOR";"459";"459";"Nude"
"COLOR";"459";"459";"Ivory"
"SIZE";"460";"460";"Large"
"SIZE";"460";"460";"Medium"
"SIZE";"460";"460";"Small"
"SIZE";"470";"470";"Large"
"SIZE";"470";"470";"Small"
"SIZE";"470";"470";"Medium"
"COLOR";"476";"476";"White"
"COLOR";"476";"476";"Black"
"SIZE";"477";"477";"Small"
但我不显示重复数据。例如,这里显示。
"COLOR";"459";"459";"Black"
"COLOR";"459";"459";"Black"
"COLOR";"459";"459";"Black"
"COLOR";"460";"60";"Black"
有什么办法吗?感谢
答案 0 :(得分:1)
也许你只想按名字分组?你似乎在调用一个似乎有不同ID的重复数据......
SELECT DISTINCT t1.class, t1.classid, t2.classid, t2.option_name
FROM table1 AS t1
INNER JOIN table AS t2 ON t1.classid = t2.classid
GROUP BY t1.class,t2.option_name