求sql语句中的where表达式,不难
表A字段
字段:whichday FromWhichWeek ToWhichWeek
字段类型:string int int
现有两个变量string a和int b对应表A这三个字段
条件一:string a 对应 Whichday,判断是否相同
条件二:int b 要进行判断是否> =FromWhichWeek并且 <=ToWhichWeek,即在FromWhichWeek和ToWhichWeek两个值的范围之内,并且可以等于。
当两个条件均成立的时候筛选出满足条件的记录,sql语句怎样写,不要带存储过程了,简单一条sql语句就可以实现的,谢谢了。
(我使用C#语句编写Asp.net程序的,所以请注意符号是否符合c#标准)
------解决方案--------------------string sql = "select * from A where Whichday = '{0} ' and {1} between FromWhichWeek and ToWhichWeek ";
sql = string.Format(sql, a, b);
------解决方案--------------------string sql = "select * from A where Whichday = ' "+a+ " ' and "+b+ " between FromWhichWeek and ToWhichWeek ";