I am trying to Update an int value (the value of a primary key, retrieved from another table named country) into the city_id column (which is a Foreign Key in the persons table from the country table), in all the rows where the value of the name attribute/column is John, Amy, Adam, Abraham, Bob, David, Robert, George, Elizabeth, Mike and Barbara.
I tried using this query but I get an exception that there is an error in my MySQL syntax.
String query1="update persons set city_id="+rid+" where "
+ "(name= 'John' and "
+ "name= 'Amy' and "
+ "name= 'Adam' and "
+ "name= 'Abraham' and "
+ "name= 'Bob' and "
+ "name= 'David' and "
+ "name= 'Robert' and "
+ "name= 'George' and "
+ "name= 'Elizabeth' and "
+ "name= 'Mike' and "
+ "name= 'Barbara' )";
I tried this by removing the parenthesis as well.
So can somebody point out what's wrong with it, or another query which can serve my purpose?