在Navicat Premium测试sql语句的时候发现提示
[SQL] select u.* from `user` u,score s where u.username=s.Name and s.Score=(select top 5 n.Score from score n order by Score desc)
[Err] 1064 - 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 '5 n.Score from score n order by Score desc)' at line 1
提示在top 5
附近出现问题,检查语句发现没问题
这是因为!
在mysql中select top用法和ms sqlserver有所区别。
若在mysql中实现select top功能得用:select * from tablename limit M,N
这里M表示从(M+1)条记录开始,N表示返回的记录条数
炒鸡重要的知识!!!