首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

求sql语句中的where表达式,不难,该怎么处理

2012-01-12 
求sql语句中的where表达式,不难表A字段字段:whichdayFromWhichWeekToWhichWeek字段类型:stringintint现有

求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 ";

热点排行