ORACLE的语句,现在改成数据库改成MYSQL,报错。Every derived table must have its own alias。跪求大神
答案:2 悬赏:80 手机版
解决时间 2021-01-16 16:27
- 提问者网友:暗中人
- 2021-01-16 00:37
ORACLE的语句,现在改成数据库改成MYSQL,报错。Every derived table must have its own alias。跪求大神
最佳答案
- 五星知识达人网友:你可爱的野爹
- 2021-01-16 00:47
Every derived table must have its own alias,这个错误的意思是说:每个派生出来的表都必须有一个自己的别名,即查询语句中所有的子查询需要有一个表名。
帮你改了一下,加上了一部分表名,重点是加上了的mid1,mid2,mid3,mid4,你自己在语句中添加一下试试。
select * from
(select a.*, rownum rn
from(select * from personnel_info pei
where pei.position_num in(select poi.position_num from position_info poi where poi.belong_dep in (select department_num from department de where de.department_name="") as mid1) as mid2 order by personnel_num desc) as mid3
a where rownum<="param") as mid4
where rn>"param" order by personnel_num desc追问不行啊,还是报错。 - -!蛋疼!追答你确定你每个子查询后面都加好了?
现在报什么错误?
帮你改了一下,加上了一部分表名,重点是加上了的mid1,mid2,mid3,mid4,你自己在语句中添加一下试试。
select * from
(select a.*, rownum rn
from(select * from personnel_info pei
where pei.position_num in(select poi.position_num from position_info poi where poi.belong_dep in (select department_num from department de where de.department_name="") as mid1) as mid2 order by personnel_num desc) as mid3
a where rownum<="param") as mid4
where rn>"param" order by personnel_num desc追问不行啊,还是报错。 - -!蛋疼!追答你确定你每个子查询后面都加好了?
现在报什么错误?
全部回答
- 1楼网友:有你哪都是故乡
- 2021-01-16 01:16
mysql中不能使用rownum。。你要用mysql中的方法实现rownum;
例如SELECt@rownum:=@rownum+1rownum, CollectSnFrom
(SELECt@rownum:=0,bbgmain.*FROMqbdb.bbgmainWHERecollectsn!=''ORDERBYcollectsn limit10) t追问能不能帮我改一下?跪求!急用!追答mysql,,我了解的也不多,我只了解oracle。追问好的,谢谢!
例如SELECt@rownum:=@rownum+1rownum, CollectSnFrom
(SELECt@rownum:=0,bbgmain.*FROMqbdb.bbgmainWHERecollectsn!=''ORDERBYcollectsn limit10) t追问能不能帮我改一下?跪求!急用!追答mysql,,我了解的也不多,我只了解oracle。追问好的,谢谢!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯