-2
|===============================|
|column_one   |     column_two  |
|===============================|
|  red        |      james      |
|  green      |      smith      |
|  blue       |      kelvin     |
|  yellow     |      james      |
|  black      |      james      |
|  purple     |      bawa       |
|  white      |      milky      |
=================================

应用查询后,应该有

|===============================|
|column_one   |     column_two  |
|===============================|
|  red        |                 |
|  green      |      smith      |
|  blue       |      kelvin     |
|  yellow     |                 |
|  black      |                 |
|  purple     |      bawa       |
|  white      |      milky      |
=================================
4

2 回答 2

0

也许类似的东西DISTINCT会帮助你:

`CREATE TEMPORARY TABLE no_duplicats AS SELECT DISTINCT * FROM table_name;
DELETE FROM table_name;
INSERT INTO table_name SELECT * FROM no_duplicats;
DROP TABLE no_duplicats;`
于 2013-07-20T16:37:04.607 回答
0

在来这里寻求帮助之前,您真的应该自己尝试一下。但是,这应该可以满足您的要求:

UPDATE table_name
SET column_two=''
WHERE column_two IN (
   SELECT * FROM (
      SELECT column_two FROM table_name
      GROUP BY column_two
      HAVING COUNT(*) > 1
   ) alias_table
)

它的工作原理是创建一个子查询来查找 的所有重复项column_two,然后“父”查询将所有这些记录设置''column_two

于 2013-07-20T16:47:49.493 回答