dongzhi9032 2014-12-14 14:17
浏览 40
已采纳

MySql - 当前一个列单元格值已知时,获取接下来的10行值

I have a Html table like below, (That's the MySql's query dump of all the ID's)

200 201 203 204 205 206 207 208 209 210 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 302 303 305 306 307

It is in the MySql database like

    -------------------
    ID        Number

    202      242
    202      243
    202      244
    202      245
    202      ...
    -------------------

The Number column is the above listed table, that's the html page. I pasted that because to better understand what my question is...

My MySql query to get the next 10 row's value is, SELECT Number FROM MyDB WHERE ID=202 ORDER BY Number ASC LIMIT 241 , 10

I am in the understanding that the above LIMIT 241 displays the rows with values next to 241.

But the problem with the above Sql query is it doesn't output the next 10 immediate values.

It produces,

    454
    455
    456
    457
    458
    459
    460
    461
    462

Instead it must output,

 241
 242
 243
 ...

That's the next immediate value.

Why it is not outputting the immediate next 10 value? and instead some other 10 values?

What would the SQL query be to output the next 10 immediate rows' values when an ID value is used to query the DB's Table?

  • 写回答

1条回答 默认 最新

  • doufusi2013 2014-12-14 14:24
    关注

    The offset is the number of rows to skip; it has nothing to do with values in the rows. I think you want:

    SELECT Number
    FROM MyDB
    WHERE ID = 202 AND number >= 241
    ORDER BY Number ASC
    LIMIT 10
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改