日期:2014-05-17  浏览次数:20977 次

请问这条SQL语句怎么写?
选择所有字段来自income表,满足的条件是   agent(文本型)字段等于   aa   ,字段date(日期型)在a(起启时间)日期到b(终止时间)日期之间.

这是我写的,但是执行不对,
    s_date=CDate(Request.form( "s_date "))                                           '起始时间
    e_date=CDate(Request.form( "e_date "))                                           '终止时间
    type1   =Request.form( "type1 ")
    exec= "select   *   from   income   where   agent=type1   and   (date   between   # "&s_date& "#   and   # "&e_date& "#) "

------解决方案--------------------
exec= "select * from income where agent= ' "&type1& " ' and (date between # "&s_date& "# and # "&e_date& "#) "

------解决方案--------------------
type1是变量,如果是文本就用楼上的写法,如果是数字就用agent= "&type1& "。
时间比较如果是access就用#如果是sql server 可以用文本的方式date between ' "&s_date& " ' and ' "&e_date& " '。