每个单独的查询(t1和t2)本身都能正常工作,但是似乎不允许进行简单的联接。
我使用表x1和x2重新创建了代码,这很好,但是在顶部复制粘贴t1和t2会使我再次出错。
这一定与变量有关吗?
问题尝试:
select *
from
(
set @rownumber1 = 0;
select (@rownumber1:= @rownumber1 + 1) as num,
id,
updated_at as date,
risk_factor
from (select * from user.users_audit order by id) orig
order by id
) t1
left join
(
set @rownumber2 = 0;
select (@rownumber2:= @rownumber2 + 1) as num,
id,
updated_at as date,
risk_factor
from (select * from user.users_audit order by id) orig
order by id
) t2 on t1.id = t2.id
尝试工作-但是我不在乎表格:
select *
from
(
select *
from sport_type_sources
) x1
inner join
(
select *
from sport_type_sources
) x2 on x1.id = x2.id
我只是想将两个表合并在一起。