表Ta
 ID     nian(整型)     yue(整型)
1          2009             2
2          2009             5
3          2009             6
4          2009             8
5          2009             1
6          2009             3
7          2009             4
8          2009             6
9          2009             10
10         2009             12
11         2009             9
12         2008             7
13         2008             2
14         2008             5
15         2008             6
16         2008             8
17         2008             1
18         2008             3
19         2008             4
20         2008             6
21         2008             10
22         2010             1
23         2010             1
24         2010             1我用过这样的SQL但都不能得到应有的数据:SELECT * FROM chengben  where nian (between 2008 and 2010) and yue<  order by chengben.guishunian,chengben.guishuyue,t.CID

解决方案 »

  1.   

    SELECT * FROM chengben  where nian (between 2008 and 2010) and yue <  order by chengben.guishunian,chengben.guishuyue,t.CID你的语法都不对,你想实现什么功能?
      

  2.   

    随便猜一下,你是不是想要这个?SELECT * FROM chengben  
    where nian*100+yue between 200812 and 201001
      

  3.   

    还没写完,误按了快捷键,结果给提上来了。下面详述:
    表Ta中存的数据为物品购买的归属年月, 我在程序中用Dropdownlist 做了四个下拉选择列表,分别为起始看月到终止年月。例如:怎样得到条件为nian大于2008年12月至2010年1月的数据?
    表Ta 
    ID    nian(整型)    yue(整型) 
    1          2009            2 
    2          2009            5 
    3          2009            6 
    4          2009            8 
    5          2009            1 
    6          2009            3 
    7          2009            4 
    8          2009            6 
    9          2009            10 
    10        2009            12 
    11        2009            9 
    12        2008            7 
    13        2008            2 
    14        2008            5 
    15        2008            6 
    16        2008            8 
    17        2008            1 
    18        2008            3 
    19        2008            4 
    20        2008            6 
    21        2008            10 
    22        2010            1 
    23        2010            1 
    24        2010            1 我用过这样的SQL但都不能得到应有的数据:SELECT * FROM chengben  where nian (between 2008 and 2010) and yue >=12 and yue <=1 
      

  4.   

    SELECT * FROM chengben  where nian*12+yue>=2008*12+12 and nian*12+yue<=2010*12+1