MariaDB社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 4408|回复: 2
打印 上一主题 下一主题

请问这样的SQL怎么写?

[复制链接]
跳转到指定楼层
1#
发表于 2008-5-28 22:20:31 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我是从SQL SERVER 数据库改成MYSQL数据库的。里面有些SQL语句语法有些小差异,我有个分页的SQL ,不知道怎么改成MYSQL 可以运行的语句?请大家帮忙?
语句是:
sql = "select top "+intpagesize+" * from article where fstatus=? and articleClass=? and articleId not in (select top "+((intpage-1)*intpagesize)+" articleId from article order by articleId desc) order by articleId desc";

如何改成在MYSQL下可以运行的语句呢?

我改成这样:

select * from article where fstatus=? and articleClass=? and articleId not in (select articleId from article order by articleId desc limit "+((intpage-1)*intpagesize)+") order by articleId desc limit "+intpagesize

报错:
This version of MySQL doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery'

我现在知道了。原来是在子查询中不能用limit

可是这句怎么拆开分成2步操作呢?

结帖了。问题已经解决!

[ 本帖最后由 fxn9801 于 2008-5-29 12:22 编辑 ]
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖 顶 踩
2#
发表于 2008-6-3 10:00:36 | 只看该作者
谢谢分享...
3#
发表于 2010-4-30 14:00:17 | 只看该作者
太感谢楼主了,我也在转移这个,学校教的是sqlsever2000,我还得一个个改,真麻烦
不过学校用delphi,我ubuntu上就难办了
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|手机版|MariaDB社区 ( 京ICP备07012489号    |
业务联系: QQ:48474881; 邮箱: 48474881@qq.com; 电话:13911732319
声明:本站部分文章是网友转载,若未经作者同意或署名有误,请联系网站管理员。

GMT+8, 2024-9-20 05:31 , Processed in 0.124717 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表