请帮忙看一下这句SQL

enjoyeagle 2003-10-24 01:26:40
初学,帮帮忙,谢谢!
if accute=1 then //accute表示是否模糊查询
OP="LIKE'"
else
OP="='"
end if
sqlstr="Select * from 表名 where 字段名"&OP&变量&"' and left(pubdate,4) between datefrom and dateto "
...全文
43 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
foow 2003-10-24
  • 打赏
  • 举报
回复

if accute=1 then //accute表示是否模糊查询
OP="LIKE '%" & 变量 & "%'"
else
OP="='" & 变量 & "'"
end if

sqlstr="Select * from 表名 where 字段名 "&OP&" and left(pubdate,4) between datefrom and dateto "

应该考虑多个变量和字段名的时候
aierong 2003-10-24
  • 打赏
  • 举报
回复


什么
好像不是sql语句
gmlxf 2003-10-24
  • 打赏
  • 举报
回复
if accute=1 then //accute表示是否模糊查询
OP="LIKE '%" & 变量 & "%'"
else
OP="='" & 变量 & "'"
end if

sqlstr="Select * from 表名 where 字段名 " & OP & " and left(pubdate,4) between '" & datefrom & "' and '" & dateto "'"
fjw2002 2003-10-24
  • 打赏
  • 举报
回复
if accute=1 then //accute表示是否模糊查询
OP="LIKE '%" & 变量 & "%'"
else
OP="='" & 变量 & "'"
end if

sqlstr="Select * from 表名 where 字段名 "&OP&" and left(pubdate,4) between datefrom and dateto "
lvltt 2003-10-24
  • 打赏
  • 举报
回复
if accute=1 then //accute表示是否模糊查询
OP="LIKE '"
else
OP="= '"
end if
sqlstr="Select * from 表名 where 字段名 "&OP&" and left(pubdate,4) between '" & datefrom & "' and '" & dateto & "'"
txlicenhe 2003-10-24
  • 打赏
  • 举报
回复
if accute=1 then //accute表示是否模糊查询
OP="LIKE '"
else
OP="= '"
end if
sqlstr="Select * from 表名 where 字段名 " & OP & 变量 & "' and left(pubdate,4) between datefrom and dateto "
pengdali 2003-10-24
  • 打赏
  • 举报
回复
如果datefrom,dateto也是变量:

if accute=1 then //accute表示是否模糊查询
OP="LIKE '%" & 变量 & "%'"
else
OP="='" & 变量 & "'"
end if

sqlstr="Select * from 表名 where 字段名 "&OP&" and left(pubdate,4) between '" & datefrom & "' and '" & dateto & "'"
pengdali 2003-10-24
  • 打赏
  • 举报
回复
if accute=1 then //accute表示是否模糊查询
OP="LIKE '%" & 变量 & "%'"
else
OP="='" & 变量 & "'"
end if

sqlstr="Select * from 表名 where 字段名 "&OP&" and left(pubdate,4) between datefrom and dateto "

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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