MYSQL: data in one column depends on another column

Viewed 1738

I need to create a table where I have columns country and city.

If I put the country as 'USA', the city must be 'New York'. How to impose this constraint?

I tried but this affects data in other rows too:

UPDATE table1 SET city = IF(country = "USA", 'New York', '');

Also, if possible the constraint should be added while creating the table.

2 Answers
Related