Click here to Skip to main content
15,907,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi !
I have some problem with MySql

I tried to test as:
SELECT * From news_content_temp where created = date_sub(curdate(),INTERVAL WEEKDAY(curdate()) +7 day);

It worked well

But I tried to delete as:
Delete From news_content_temp where created = date_sub(curdate(),INTERVAL WEEKDAY(curdate()) +7 day);

It did not Work?

Why???? or It was a wrong way?
Posted
Updated 21-Jun-11 16:18pm
v2
Comments
OriginalGriff 21-Jun-11 10:32am    
When you say "it didn't work" what happened? Did you get an error message?

add SET SQL_SAFE_UPDATES=0; before the query
 
Share this answer
 
The error message was:

Error Code: 1175. To disable safe mode, toggle the option in Preferences -> SQL Editor -> Query Editor and reconnect.
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
 
Share this answer
 
So, How can I set it forever? No need to set it whenever I open WorkBench?
 
Share this answer
 
SET SQL_SAFE_UPDATES=0; should be added before the query and
after the query it should be changed to 1 i.e. SET SQL_SAFE_UPDATES=1;

If set to 1, MySQL will abort if an UPDATE or DELETE is attempted that doesn't use a key or LIMIT in the WHERE clause. This makes it possible to catch wrong updates.

So, it is better you use this for every query by setting it to 0 and then resetting to 1.
 
Share this answer
 
v2
Comments
character_kute 22-Jun-11 1:03am    
Thanks for sharing!
arathi_suresh 22-Jun-11 1:25am    
Welcome! Pls mark as solution, green button

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900