查询指定字段值相同的记录

-- 查询prefix_city表里面pinyin字段值相同的记录
SELECT
  *
FROM
  `prefix_city`
WHERE
    `pinyin` IN (
    SELECT
      `pinyin`
    FROM
      `prefix_city`
    GROUP BY
      `pinyin`
    HAVING
        COUNT(`pinyin`) > 1
  )
ORDER BY
  `pinyin`;

Copyright © 2024 码农人生. All Rights Reserved