mysql 虚拟列连接问题

select @rd := @rd+1 as rownum, b.qishu from (select @rd:=1, qishu,(one+two) as xxx from lotto_ppp HAVING xxx = 3 order by qishu DESC) b
上面这条语句执行的结果是图片描述

select @rd := @rd+1 as rownum, a.qishu from (select @rd:=0, qishu,(one+two) as xxx from lotto_ppp HAVING xxx = 3 order by qishu DESC) a
这条语句执行的结果为图片描述

为什么最终执行的这条语句连接不起来
SELECT g1.,g2. FROM (select @rd := @rd+1 as rownum, b.qishu from (select @rd:=1, qishu,(one+two) as xxx from lotto_ppp HAVING xxx = 3 order by qishu DESC) b) AS g1
LEFT JOIN ( select @rd := @rd+1 as rownum, a.qishu from (select @rd:=0, qishu,(one+two) as xxx from lotto_ppp HAVING xxx = 3 order by qishu DESC) a ) AS g2
ON g1.rownum = g2.rownum;
图片描述

g2表的东西都是空的

阅读 1.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题