I want to delete specific values/data from one column with the WHERE condition. Putting in another way, I don't want to delete the complete row. Is it possible?
我想使用WHERE条件从一列中删除特定值/数据。换句话说,我不想删除完整的行。可能吗?
4 个解决方案
#1
37
UPDATE TABLE SET columnName = null WHERE YourCondition
#2
13
You don't want to delete if you're wanting to leave the row itself intact. You want to update the row, and change the column value.
如果您想要保持行本身不变,则不想删除。您想要更新行,并更改列值。
The general form for this would be an UPDATE
statement:
一般形式是UPDATE语句:
UPDATE <table name>
SET
ColumnA = <NULL, or '', or whatever else is suitable for the new value for the column>
WHERE
ColumnA = <bad value> /* or any other search conditions */
#3
13
UPDATE myTable
SET myColumn = NULL
WHERE myCondition
#4
3
You can also use REPLACE().
您也可以使用REPLACE()。
UPDATE Table SET Column = REPLACE(Column, 'Test123', 'Test')
UPDATE表SET列= REPLACE(列,'Test123','测试')
#1
37
UPDATE TABLE SET columnName = null WHERE YourCondition
#2
13
You don't want to delete if you're wanting to leave the row itself intact. You want to update the row, and change the column value.
如果您想要保持行本身不变,则不想删除。您想要更新行,并更改列值。
The general form for this would be an UPDATE
statement:
一般形式是UPDATE语句:
UPDATE <table name>
SET
ColumnA = <NULL, or '', or whatever else is suitable for the new value for the column>
WHERE
ColumnA = <bad value> /* or any other search conditions */
#3
13
UPDATE myTable
SET myColumn = NULL
WHERE myCondition
#4
3
You can also use REPLACE().
您也可以使用REPLACE()。
UPDATE Table SET Column = REPLACE(Column, 'Test123', 'Test')
UPDATE表SET列= REPLACE(列,'Test123','测试')