当我执行下面的查询时,它抛出错误:语法错误位于“ as”或附近。
我们该如何解决?
还有其他方法吗?
(select * from my_table1 where status='6') as a
left JOIN
(select * from my_table1 where status='1') as b
ON (a.application_id = b.application_id)
答案 0 :(得分:1)
通过使用子查询中的选择,像下面一样尝试
select a.* from (select * from my_table1 where status='6') as a
left JOIN
(select * from my_table1 where status='1') as b
ON a.application_id = b.application_id
答案 1 :(得分:1)
您缺少初始的select * from
子句。此外,不需要子查询;您只需要注意条件的放置。
select *
from my_table1 a
left join my_table1 b on b.status='1' and
b.application_id = a.application_id
where a.status='6'
答案 2 :(得分:0)
您已经从子查询中选择了所有值并将它们联接:
select a.* from (select * from my_table1 where status='6') as a
left JOIN
select b.* from (select * from my_table1 where status='1') as b
ON (a.application_id = b.application_id)
答案 3 :(得分:0)
select * from my_table1 as A
LEFT JOIN my_table1 as B
ON (A.application_id = A.application_id)
WHERE A.status='6' AND B.status='1'