1

I am trying to search the table actions in my database and delete any value within the code column that has the value of 40.

I have tried:

REPLACE (code,40,'') 
FROM actions 

but no luck. Also tried the DELETE function.

1

1 Answer 1

3

You're looking for UPDATE:

Update   actions
Set      code = Null
Where    code = 40

If you need to delete the entire row, you can do it with the following:

Delete   
From     actions
Where    code = 40
Sign up to request clarification or add additional context in comments.

11 Comments

When I tried that I get the following error message:
NOT NULL constraint failed: actions.code: Update actions Set code = Null Where code = 40
You have a NOT NULL constraint on your column that you're trying to set to NULL. You will either need to update the column definition, or set the value to something other than NULL (i.e. 0 or -1 - this depends on your data and how you use it.)
Problem though! I just found out that I need to delete any row instead of deleting the the cell content where that data shows up. How can i do that?
I would HIGHLY recommend putting this in a TRANSACTION before running it, then verifying that you get what you need before you COMMIT it. It's a whole lot easier to ROLLBACK than it is to restore from a backup.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.