Reputation: 6555
Can the UPDATE
query be used without a WHERE
clause? And if so in what conditions?
Upvotes: 36
Views: 98916
Reputation: 39
UPDATE test.test SET name='aaaa' WHERE true
This updates all the rows and gets rid of the error Unsafe query: 'Update' statement without 'where' updates all table rows at once
Upvotes: 1
Reputation: 855
The UPDATE
statement in SQL is used to update records in the table. We can modify one or multiple records (rows) in a table using UPDATE
statement. If you do not use WHERE
clause in UPDATE
statement, all the records in the table will be updated.
Upvotes: 1
Reputation: 31
So, I think when you want to update the whole field for some kind of reasons like updating the status of users enrollment to free for all users.
UPDATE users SET status = "free";
Upvotes: 3
Reputation: 26737
if you don't use the WHERE
clause all the records on the table will be affected
Upvotes: 48