| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 444 人关注过本帖
标题:拼sql问题
取消只看楼主 加入收藏
sm105096496
Rank: 1
等 级:新手上路
帖 子:58
专家分:0
注 册:2007-7-11
收藏
 问题点数:0 回复次数:0 
拼sql问题

public DataTable ShowFindscout(string name,string verid)
{
string strline=name;
string [] aryline=null;
string ss="";
aryline = strline.Split(new char[] { ',' });
if(aryline.Length>=2)
{
for (int j = 0; j< aryline.Length; j++)
{
if (j==(aryline.Length-1))
{
ss=ss+"Coupon LIKE '%" +aryline[j]+"%' or "+"Chrcontent LIKE '% or "+aryline[j]+"%' or "+"Keyword LIKE '%"+aryline[j]+"%'";

}
else
{
ss=ss+"Coupon LIKE '%" +aryline[j]+"%' or "+"Chrcontent LIKE '% or "+aryline[j]+"%' or "+"Keyword LIKE '%"+aryline[j]+"%' or ";
}
}
}
else
{
for (int j = 0; j< aryline.Length; j++)
{
ss="Coupon LIKE '%" +aryline[j]+"%' or "+"Chrcontent LIKE '%"+aryline[j]+"%' or "+"Keyword LIKE '%"+aryline[j]+"%'";
}
}
myConn.dbQuery("select Nid,Chrtitle,Chrcontent,Dtappenddate from Life_find where Isopen=1 and verid="+verid+" and ("+ss+") ");
return myConn.FileValue;
}
上面是我写的代码 传值例如:a,b,c
得到 SQL入下

select * from where verid=2 and (Coupon LIKE '%a' or Chrcontent LIKE '%a' Keyword LIKE '%a' or Coupon LIKE '%b' or Chrcontent LIKE '%b' Keyword LIKE '%b' or Coupon LIKE '%c' or Chrcontent LIKE '%c' Keyword LIKE '%c')

现在想把上面的方法改下 传值成 a,b,c|A,B,C
得到SQL如下:请帮我改下

select * from where verid=2 and (Coupon LIKE '%a' or Chrcontent LIKE '%a' Keyword LIKE '%a' or Coupon LIKE '%b' or Chrcontent LIKE '%b' Keyword LIKE '%b' or Coupon LIKE '%c' or Chrcontent LIKE '%c' Keyword LIKE '%c') and (Coupon LIKE '%A' or Chrcontent LIKE '%A' Keyword LIKE '%A' OR Coupon LIKE '%B' or Chrcontent LIKE '%B' Keyword LIKE '%B')

搜索更多相关主题的帖子: sql 
2007-09-11 16:18
快速回复:拼sql问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011305 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved