MySQL Update Error...

admin

Administrator
Staff member
Ok, I've been staring at this one sql statement for 2 days now and I can't seem to figure out why its giving me an error...

"update my_table set field_1='$my_value' where field_1='$cond_1' and field_2='$cond_2' limit $my_limit"

In the table that I'm targeting, there are thousands of entries that match the where clause, but I only want to change a certain amount of them... hence the limit. But when I run this code, I get this error...

You have an error in your SQL syntax near 'limit 10' at line 1

I checked on the MySQL documentation and you can use limits in an update statement, but it just doesn't seem to work for some reason, maybe I'm missing something, any help would be much appreciated. Thank you.
 
Back
Top