简体   繁体   中英

get reference table by foreign key

I have two table user and course where user_id is in table of course as foreign key.

How can I get referenced table from foreign key in php laravel framework. I mean is it possible ?

Any solution or other guide will be appreciate it.

Thank you!

如果我理解正确,那么可以查询information_schema以获得以下信息:

SELECT `REFERENCED_TABLE_NAME` FROM `INFORMATION_SCHEMA`.`KEY_COLUMN_USAGE` WHERE `REFERENCED_TABLE_SCHEMA` = 'your_database' AND `TABLE_NAME` = 'course' AND `COLUMN_NAME` = 'user_id';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM