tags:

views:

12

answers:

2

Sorry if the question is stupid but I'm newbie to MySQL and got stuck with this.

Let's suppose I have the following table in MySQL:

City.........Country.....Restaurants
Rome......Italy.............3032
Paris.......France........5220

I want to search for the city "Paris" and update the field "Restaurants" (replace 5220 with 5300).

What would be the right MySQL query?

Thanks in advance!

A: 

UPDATE table SET Restaurants=5300 WHERE City='Paris'

You could also add AND Restaurants=5220 to the WHERE clause to be even more specific.

webdestroya
What an incredible site is this! Just found it and got an answer in five minutes! You are awesome! Thanks for the instant reply!!!
Francisco
@Francisco - No problem. Just be sure to mark your question as answered so that others can learn.
webdestroya
A: 

Seems like you're looking for UPDATE.

UPDATE table SET Restaurants = 5300 WHERE city = 'Paris'

Keep in mind that if these values (5300 or Paris) are coming from the user, you should make sure to sanitize them. Or better yet, use prepared statements.

munch
What an incredible site is this! Just found it and got an answer in five minutes! You are awesome! Thanks for the instant reply!!!
Francisco