mysql 中的s表中有一字段名为floor (楼层的意思) 值 如 5/6 意为第五层 总层数为6 现想查 第5层 的所有记录 怎么实现呀,多谢select * from 表 where floor like '5/%' select * from 表 where floor like '%5/%' SQL code: select * from s表 where `floor` like '5/%'
按楼主的意思,如果共6屋,查第五层直接 where fllor='5/6',否则where fllor like '%5/%'查所有楼的第五层! select * from s表 where `floor` like '5/%'
非 select * from s表 where `floor` like '%5/%' 后者有可能搜到15楼,25楼 学习了 select * from `s表` wherefloor regexp "^5/[0-9]$";
SQL code:
select * from `s表` where floor regexp "^5/[0-9]+$";
先上错误 无法联接数据库 java.sql.SQLException: Before start of result set at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:910) at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.java: ......