Why I am not able to update the column based on a condition which is not the primary key
Posted
by Gaurav Sharma
on Stack Overflow
See other posts from Stack Overflow
or by Gaurav Sharma
Published on 2010-05-18T10:47:00Z
Indexed on
2010/05/18
10:50 UTC
Read the original article
Hit count: 412
Why I am not able to update the column based on a condition which is not the primary key.
I am trying to update the constituencies table where name matches a specific criterial as shown below but the below queries shows an error
Error code 1064, SQL state 42000: 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 'table constituencies set city_id = '1' where constituencies.name = "East Delhi"' at line 1
update table constituencies set city_id = '1' where constituencies.name = "East Delhi";
update table constituencies set city_id = '1' where constituencies.name = "South Delhi";
update table constituencies set city_id = '1' where constituencies.name = "Delhi Sadar";
update table constituencies set city_id = '1' where constituencies.name = "Karol Bagh";
update table constituencies set city_id = '1' where constituencies.name = "New Delhi";
update table constituencies set city_id = '1' where constituencies.name = "Outer Delhi";
update table constituencies set city_id = '1' where constituencies.name = "North East Delhi";
update table constituencies set city_id = '1' where constituencies.name = "North West Delhi";
update table constituencies set city_id = '1' where constituencies.name = "West Delhi";
Is it necessary that the condition should be checked with a primary key only ?
Please throw some light on the above.
© Stack Overflow or respective owner