select lt.name from location l join sales_person as lt on l.location_to = lt.id
UNION ALL
select lf.name from location l join sales_person as lf on l.location_from = lf.id
加入 sales_person 两张table location 为…取名字 location_to 以及 location_from ``` select t.name,f.name from location l join sales_person t on l.location_to = t.id join sales_person f on l.location_from = f.id
2条答案
按热度按时间4si2a6ki1#
也可以对单个查询使用union。
yjghlzjz2#
加入
sales_person
两张tablelocation
为…取名字location_to
以及location_from
```select t.name,f.name
from location l
join sales_person t on l.location_to = t.id
join sales_person f on l.location_from = f.id