I have a table which contains two columns of Urls and it contains duplicates.I'm looping through each row but have no idea to check duplicates.I want to send oldurl as parameter to check duplicates and get them.I don't want count but the list of all the duplicates.Can anyone help me
我有一个包含两列Urls的表,它包含重复项。我循环遍历每一行但不知道检查重复项。我想发送oldurl作为参数来检查重复项并获取它们。我不想要数但所有重复的列表。任何人都可以帮助我
OldUrl NewUrl
---------------------
Google Google.in
Amazon Amazon.in
1 个解决方案
#1
SELECT oldurl
FROM mytable
GROUP BY oldurl
HAVING COUNT(*) >1
or if you need to see all duplicated records:
或者如果您需要查看所有重复的记录:
SELECT mytable.*, t.counter
FROM mytable
INNER JOIN(
SELECT oldurl, COUNT(*) as counter
FROM mytable
GROUP BY oldurl
HAVING COUNT(*) >1) t
ON t.oldurl=mytable.oldurl
#1
SELECT oldurl
FROM mytable
GROUP BY oldurl
HAVING COUNT(*) >1
or if you need to see all duplicated records:
或者如果您需要查看所有重复的记录:
SELECT mytable.*, t.counter
FROM mytable
INNER JOIN(
SELECT oldurl, COUNT(*) as counter
FROM mytable
GROUP BY oldurl
HAVING COUNT(*) >1) t
ON t.oldurl=mytable.oldurl