答案 0 :(得分:0)
如果要查找列中包含重复项的记录,可以使用此查询:
SELECT T1.* FROM tbl T1
JOIN
(SELECT id
FROM (
SELECT id, sample1 AS n from tbl
UNION ALL
SELECT id, sample2 AS n from tbl
UNION ALL
SELECT id, sample3 AS n from tbl
) AS X
GROUP BY id, n
HAVING COUNT(*) > 1
) T2
ON T1.id = T2.id;
您还可以对其进行测试Here
答案 1 :(得分:-1)
我不确定MySql
,
但是在下面的PHP
示例中将使用。
示例强>
$query = "select * from table_name";
$result = mysqli_query($query);
while ($row = mysqli_fetch_array($result)) {
if ($row['sample1'] == $row['sample2']) {
// This row duplicate
}
else {
// This row not duplicate
}
}
答案 2 :(得分:-2)
SELECT Sample1, COUNT(*) C FROM tablename GROUP BY Sample1 HAVING C > 1;