判断有无重复的字段值

SELECT *
FROM (SELECT regcode, COUNT(*) AS nNumber
        FROM z1
        GROUP BY regcode) DERIVEDTBL
WHERE (nNumber > 1)

 

选择员工表里名字相同的记录

ELECT *
FROM users
WHERE (name IN
          (SELECT name
         FROM users
         GROUP BY name
         HAVING COUNT(*) > 1))
ORDER BY name DESC

你可能感兴趣的:(职场,休闲,判断有无重复的字段值)