且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

2 引用 MySQL 中相同主键的外键

更新时间:2023-02-02 23:32:54

您需要使用两个连接来完成此操作.

You need to use two joins to accomplish this.

例如:

select f.friendsID, 
  s1.name as personA_name, 
  s2.name as personB_name
from friends f
  inner join student s1 on s1.sID = f.personA
  inner join student s2 on s2.sID = f.personB