首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

sql语句找不着这个异常啊

2012-06-10 
sql语句找不着这个错误啊!select top 3 student.StudentName as studentname,student.StudentId as studen

sql语句找不着这个错误啊!
select top 3 student.StudentName as studentname,student.StudentId as studentid,student.MatriNo as matrino,speciality.SpecialityName as specialityname from student,speciality where student.SpecialityId=speciality.SpecialityId and student.SpecialityId=? and student.StudentName like ? order by StudentId desc 
我用的是mysql数据库,运行到这里时老师提示错误:com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '3 student.StudentName as studentname,student.StudentId as studentid,student.Matr' at line 1
我是比较菜的,这错误困扰多时,请各位高手帮忙看看啦!

[解决办法]
在mysql里用limit限制记录数
SELECT * FROM 表 LIMIT 3

[解决办法]
在mysql的语法中是没有top的。top是在sqlServer中用的。
[解决办法]
top是sql中的 如果是mysql 使用limit 0,3从0开始取三个
[解决办法]
mysql简单分页:
select * from tableName order by id limit start,end;

其中start和end分别是行的索引

热点排行