求一sql语句

一路奔跑1314 2013-03-18 10:34:22
有一变量strname=session("xm")
有一表为tabA,其中一字段为lct
求tabA中字段lct包含strname的记录
strsql="?"
请问?号处该如何写
...全文
190 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
梅梅2012 2013-03-18
  • 打赏
  • 举报
回复
引用 8 楼 yhj464079080 的回复:
string strname=session("xm").toString(); string strsql= string.format(" select * from tabA where lct like '%{0}%'",strname);
+1
Dotar 2013-03-18
  • 打赏
  • 举报
回复
如上 回帖
EnForGrass 2013-03-18
  • 打赏
  • 举报
回复
string sql=" select * from tabA where CHARINDEX('"+strname+"',lct)>0"; charindex的用法请参考http://www.cnblogs.com/lkvm114/archive/2011/03/06/1972261.html
yinshizi 2013-03-18
  • 打赏
  • 举报
回复
引用 4 楼 yhj464079080 的回复:
SQL code?1string strsql= string.format(" select * from tabA where lct like '%{0}%'",strname);
+1
LemonSmile_ 2013-03-18
  • 打赏
  • 举报
回复
string.format("select * from tabA where ict like '%{0}%'",strname);
yhj464079080 2013-03-18
  • 打赏
  • 举报
回复
string strname=session("xm").toString(); string strsql= string.format(" select * from tabA where lct like '%{0}%'",strname);
天下如山 2013-03-18
  • 打赏
  • 举报
回复

string.format(" select * from tabA where CHARINDEX('{0}',lct)>0",strname);
string.format(" select * from tabA where lct like '%{0}%'",strname);
一路奔跑1314 2013-03-18
  • 打赏
  • 举报
回复
引用 1 楼 lin11211408 的回复:
select lct from tabA where lct like '%strname%'
不对,直接把strname当字符串了
白云任去留 2013-03-18
  • 打赏
  • 举报
回复
string strsql = "Select * From tabA Where CHARINDEX('"+ strname +"',lct)>0";
yhj464079080 2013-03-18
  • 打赏
  • 举报
回复
string strsql= string.format(" select * from tabA where lct like '%{0}%'",strname);
md5e 2013-03-18
  • 打赏
  • 举报
回复
sql="Select * From tabA Where lct='"+ strname +"'"
Change_L 2013-03-18
  • 打赏
  • 举报
回复
string.Format("select * from tabA where lct='{0}',strname);
lin11211408 2013-03-18
  • 打赏
  • 举报
回复
select lct from tabA where lct like '%strname%'

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧