Reputation: 375
As the question says, what is the MySQL command to check if a field of table A is already referenced to a field of table B as the foreign key? Are there any commands to let the user know it?
Upvotes: 1
Views: 44
Reputation: 8942
You can use the systems table for this purpose, however from your previous question I think this might be the wrong way to achieve whatever you are trying to achieve.
http://dev.mysql.com/doc/refman/5.6/en/innodb-sys-foreign-table.html
Upvotes: 0
Reputation: 172458
Are you looking for something like this:-
USE information_schema;
SELECT *
FROM
KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_NAME = 'A'
AND REFERENCED_COLUMN_NAME = 'A_id';
Upvotes: 1