什么是此查询的正确解决方案

时间:2020-01-19 05:32:29

标签: mysql sql

您的SQL语法有误;检查与您的MariaDB服务器版本相对应的手册以获取正确的语法,以在'alias1)联接附近使用(在第1行的*从(route b join stop stopb on b.stop = stopb.id)中选择*作为a

select * 
from 
  (select * from (route a join stops stopa on a.stop=stopa.id) as alias1)
join 
  (select * from (route b join stops stopb  on b.stop=stopb.id) as alias 2)
on alias1.num=alias2.num and alias1.company=alias2.company

1 个答案:

答案 0 :(得分:0)

您需要为子查询添加别名:

select * 
from 
  (select * from route a join stops stopa on a.stop=stopa.id) as alias1
join 
  (select * from route b join stops stopb on b.stop=stopb.id) as alias2
on alias1.num=alias2.num and alias1.company=alias2.company