一本书: 章 节 内容 1 1
1 2
1 3
1 4
2 1
2 2
2 3
3 1
4 1
4 2
4 3
4 4
查询从第2章第2节到第4章第3节之间的内容?

解决方案 »

  1.   

    select * from a 
    where 章 = 2 and 节>2
    union
    select * from a 
    where 章 > 2 and 章 <4
    union
    select * from a 
    where 章 = 4 and 节 <3
      

  2.   

    或者你可以将章节写成2001(第2章第1节),2003(第2章第3节)
    然后就可以直接比较了。
    (也可以用sql实现。)
      

  3.   

    select * from a 
    where 章 = 2 and 节>2unionselect * from a 
    where 章 = 4 and 节 <3