表cw 字段state 字典adics strSql += " AND cw.state Like '%" + tbSearch.Text.Trim() + "%'"; cw.state 我该怎么改
sql+=" And exists (select top 1 1 from otherTable with(nolock) where someid = mainTable.someid)" 用不用 with(nolock) 看你需要,otherTable 、mainTable、someid 应该看得懂代表啥意思吧
sql+=" And exists (select top 1 1 from otherTable with(nolock) where someid = mainTable.someid And anotherid=@InputValue)"
string strSql = @"select cwbx.sbTime,cwbx.money,cwbx.id,d6.dicname zffs, cwbx.reason,cwbx.number,d1.dicname subject,d2.dicname state,d3.chrDeptName dept,d4.chrName sbr,d5.dicname cwdept from cwbx left join aDics d1 ON cwbx.subject = d1.dicvalue and d1.pid = 21 left join aDics d2 ON cwbx.state = d2.dicvalue and d2.pid = 22 left join aDics d5 ON cwbx.cwdept = d5.dicvalue and d5.pid = 24 left join aDics d6 ON cwbx.zffs = d6.dicvalue and d6.pid = 23 left join tbdept d3 ON cwbx.dept=d3.iddept left join tbEmployee d4 ON cwbx.sbr=d4.idUser where 1=1";
string strSql = @"select cwbx.sbTime,cwbx.money,cwbx.id,d6.dicname zffs, cwbx.reason,cwbx.number,d1.dicname subject,d2.dicname state,d3.chrDeptName dept,d4.chrName sbr,d5.dicname cwdept from cwbx left join aDics d1 ON cwbx.subject = d1.dicvalue and d1.pid = 21 left join aDics d2 ON cwbx.state = d2.dicvalue and d2.pid = 22 left join aDics d5 ON cwbx.cwdept = d5.dicvalue and d5.pid = 24 left join aDics d6 ON cwbx.zffs = d6.dicvalue and d6.pid = 23 left join tbdept d3 ON cwbx.dept=d3.iddept left join tbEmployee d4 ON cwbx.sbr=d4.idUser where 1=1";
if (tbSearch.Text.Trim() != "") strSql += @" AND cwbx.zffs in(select dicname from aDics where dicvalue=cwbx.zffs and pid=23) +cwbx.reason+ convert(varchar(50),cwbx.money)+ convert(varchar(50),cwbx.number) Like '%" + tbSearch.Text.Trim() + "%'";
表cw 字段state 字典adics strSql += " AND cw.state Like '%" + tbSearch.Text.Trim() + "%'"; cw.state 我该怎么改
sql+=" And exists (select top 1 1 from otherTable with(nolock) where someid = mainTable.someid)"
用不用 with(nolock) 看你需要,otherTable 、mainTable、someid 应该看得懂代表啥意思吧
string strSql = @"select cwbx.sbTime,cwbx.money,cwbx.id,d6.dicname zffs,
cwbx.reason,cwbx.number,d1.dicname subject,d2.dicname state,d3.chrDeptName dept,d4.chrName sbr,d5.dicname cwdept
from cwbx
left join aDics d1 ON cwbx.subject = d1.dicvalue and d1.pid = 21
left join aDics d2 ON cwbx.state = d2.dicvalue and d2.pid = 22
left join aDics d5 ON cwbx.cwdept = d5.dicvalue and d5.pid = 24
left join aDics d6 ON cwbx.zffs = d6.dicvalue and d6.pid = 23
left join tbdept d3 ON cwbx.dept=d3.iddept
left join tbEmployee d4 ON cwbx.sbr=d4.idUser
where 1=1";
string strSql = @"select cwbx.sbTime,cwbx.money,cwbx.id,d6.dicname zffs,
cwbx.reason,cwbx.number,d1.dicname subject,d2.dicname state,d3.chrDeptName dept,d4.chrName sbr,d5.dicname cwdept
from cwbx
left join aDics d1 ON cwbx.subject = d1.dicvalue and d1.pid = 21
left join aDics d2 ON cwbx.state = d2.dicvalue and d2.pid = 22
left join aDics d5 ON cwbx.cwdept = d5.dicvalue and d5.pid = 24
left join aDics d6 ON cwbx.zffs = d6.dicvalue and d6.pid = 23
left join tbdept d3 ON cwbx.dept=d3.iddept
left join tbEmployee d4 ON cwbx.sbr=d4.idUser
where 1=1";
if (tbSearch.Text.Trim() != "")
strSql += @" AND cwbx.zffs in(select dicname from aDics where dicvalue=cwbx.zffs and pid=23)
+cwbx.reason+ convert(varchar(50),cwbx.money)+ convert(varchar(50),cwbx.number) Like '%" + tbSearch.Text.Trim() + "%'";