In a mySQL database I have two populated tables. Their structures are as in the image. When trying to relate them on idArticol (in PhpMyAdmin), an error appears: "Relation could not be added". I have more than 6000 records in each table. Apparently, the error comes from a missing foreign key from the parent table. Is there an SQL command that can help me find this missing key?
You can find the missing key by using this command
SELECT * FROM userart WHERE idArticol NOT IN (SELECT idArticol FROM articol)
This will give you all entrys in userart having an idArticol that is not in articol.idArticol