Answer the question
In order to leave comments, you need to log in
How to avoid error when linking two mysql tables?
Hello. There are two tables.
cities
city_id - primary key
city_name
and users
id - primary keys
Name
age
city_id
You need to do this:
Data about users is stored in the users table, about cities in the cities table, the tables are interconnected by the city_id field
ALTER TABLE `users` ADD FOREIGN KEY (`city_id`) REFERENCES `cities`(`city_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
; Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question