例如有张表: table1
A:       ID           Name
          1             a
          2             b
          4             c
          6             d
          9             e
          11            f
          12            g
          15            h

ID值并不是连续的,如何读取到中间一段数据,例如第三行到第六行的记录?

这只是sql server下面可以:
select top 3 * from table1 where ID not in (select top 3 ID from table1)  (通过测试)


在mysql下面没有top关键字,但是我们可以用limit关键字:

select * from tb1 where id not in (select id from tb1 limit 10)

这题笔试常考,也很容易出错,网上答案乱七八糟,很多都是错的,所以最好还是亲历亲为。

相关文章:

  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2021-08-28
  • 2021-10-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-20
  • 2022-02-04
  • 2021-12-30
  • 2021-07-18
  • 2021-11-18
  • 2022-12-23
相关资源
相似解决方案