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分别是行的索引