Delete specific values from column with where condition?

前端 未结 5 972
予麋鹿
予麋鹿 2021-02-05 02:37

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?

相关标签:
5条回答
  • 2021-02-05 02:48

    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 <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 */
    
    0 讨论(0)
  • 2021-02-05 02:50
    UPDATE YourTable SET columnName = null WHERE YourCondition
    
    0 讨论(0)
  • 2021-02-05 02:57

    Try this SQL statement:

    update Table set Column =( Column - your val )
    
    0 讨论(0)
  • 2021-02-05 03:09

    You can also use REPLACE():

    UPDATE Table
       SET Column = REPLACE(Column, 'Test123', 'Test')
    
    0 讨论(0)
  • 2021-02-05 03:14
    UPDATE myTable 
       SET myColumn = NULL 
     WHERE myCondition
    
    0 讨论(0)
提交回复
热议问题