I can’t use ‘time’ word as my column name in mysql query.
This is my query code:(Not Working)
UPDATE ip_p SET deger = '-1' TIME = '123' WHERE ip = '12' AND premium = '1'
Error is:
#1064 – You have an error in your SQL syntax; check the manual that
corresponds to your MySQL server version for the right syntax to use
near ‘time=’123′ WHERE ip = ’12’ AND premium = ‘1” at line 1
But this code is working:
UPDATE ip_p SET deger = '-1' WHERE ip = '12' AND premium = '1'
Will I have to change my column name?
1) You’re missing coma (,) after
deger = '-1'2) You may enclose TIME into backticks (`) to prevent other possible errors
Correct (try it?) query spelling:
UPDATE
Responding to comment:
correct query for decreasing
degercolumn by 1 will be:If you just need to set it to -1 then do:
Also please note that syntax with single quotes (‘) should be used only with strings (varachar(…) columns etc.); for numbers that is incorrect. If you need to specify the number – just do it without any quotes. I’ve changed this for
degercolumn (apparently it’s numeric if you want to subtract something from it) but not for the others because I don’t know their types. If columnsTIME,ipandpremiumare also numbers then you’ll need to also remove quotes from their values.