Oracle.Query中MySQL Limit的等价物包括几个表?
我在 MySQL 中有以下查询,希望将其转换为 Oracle。我尝试了Oracle中的row_number()函数和子查询,但无法使其正常运行。该查询有点奇怪并且涵盖多个表。
原始 MySQL 查询:
select DISTINCT uc.virtual_clip_id, uc.clip_id, uc.duration, uc.title,
uc.thumbnail,uc.filename, uc.description, uc.block_id_start,
uc.block_id_end, u.uname,uc.cdate, uc.ctime, uc.privacy_level, uc.user_id
FROM
user_clips uc, users u, user_like ul
WHERE
ul.user_id="+user_id+" and u.user_id=uc.user_id and
uc.virtual_clip_id=ul.virtual_clip_id and ul.like_status='1'
ORDER by
virtual_clip_id DESC
LIMIT "+offset+",4"
我找不到替换 LIMIT 的正确语句,因此使查询针对 Oracle 运行。
谢谢。
I have the following query in MySQL and want to convert it to Oracle. I tried row_number() function and subqueries in Oracle but could not make it run properly. The query is kinda weird and covers multiple tables.
Original MySQL Query:
select DISTINCT uc.virtual_clip_id, uc.clip_id, uc.duration, uc.title,
uc.thumbnail,uc.filename, uc.description, uc.block_id_start,
uc.block_id_end, u.uname,uc.cdate, uc.ctime, uc.privacy_level, uc.user_id
FROM
user_clips uc, users u, user_like ul
WHERE
ul.user_id="+user_id+" and u.user_id=uc.user_id and
uc.virtual_clip_id=ul.virtual_clip_id and ul.like_status='1'
ORDER by
virtual_clip_id DESC
LIMIT "+offset+",4"
I could not find the proper statement to replace LIMIT so make the query run against Oracle.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这有点痛苦,但你可以使用 rownum
我子选择两次的唯一原因是不同的是执行一个组,并且我将排序保留在它之外,它可以通过单个子选择来完成。
It's a bit of a pain but you can use rownum
The only reason I subselected twice was the distinct is performing a group and I kept the ordering outside of it, it could be done with a single subselect.