以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]select语句的条件表达式中1=1的用法是错的吗? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=71208) |
-- 作者:huangfanzi -- 发布时间:2015/7/7 12:38:00 -- [求助]select语句的条件表达式中1=1的用法是错的吗? 在select的where中,执行下图的条件后,提示语法错误,发现问题出在 1=1 上,这个用法不对吗? [此贴子已经被作者于2015/7/7 12:37:48编辑过]
|
-- 作者:baicaocao -- 发布时间:2015/7/7 13:34:00 -- 没错 |
-- 作者:huangfanzi -- 发布时间:2015/7/7 14:28:00 -- 但是加上1=1 就执行出错,去掉后就能正常执行了。 |
-- 作者:jialihaha -- 发布时间:2015/7/7 14:33:00 -- 你确定是在sql语句里的么 [此贴子已经被作者于2015/7/7 14:34:14编辑过]
|
-- 作者:大红袍 -- 发布时间:2015/7/7 14:45:00 -- 执行出错,提示什么?整条sql语句怎么写? |
-- 作者:huangfanzi -- 发布时间:2015/7/7 15:55:00 -- Dim flt As String = "1=1" If e.Form.Controls("RadioButton_合同签订_YES").Checked = True Then flt = flt & " And [执行过程] Like \'%合同已签订%\'" Else If e.Form.Controls("RadioButton_合同签订_NO").Checked = True Then flt = flt & " And ([执行过程] Not Like \'%合同已签订%\' or [执行过程] is Null)" End If If e.Form.Controls("RadioButton_货款申请_YES").Checked = True Then flt = flt & " And [执行过程] Like \'%货款已申请%\'" Else If e.Form.Controls("RadioButton_货款申请_NO").Checked = True Then flt = flt & " And ([执行过程] Not Like \'%货款已申请%\' or [执行过程] is Null)" End If If e.Form.Controls("RadioButton_货款支付_YES").Checked = True Then flt = flt & " And [执行过程] Like \'%货款已支付%\'" Else If e.Form.Controls("RadioButton_货款支付_NO").Checked = True Then flt = flt & " And ([执行过程] Not Like \'%货款已支付%\' or [执行过程] is Null)" End If If e.Form.Controls("RadioButton_货物入库_YES").Checked = True Then flt = flt & " And [执行过程] Like \'%货物已入库%\'" Else If e.Form.Controls("RadioButton_货物入库_NO").Checked = True Then flt = flt & " And ([执行过程] Not Like \'%货物已入库%\' or [执行过程] is Null)" End If If e.Form.Controls("RadioButton_质保收到_YES").Checked = True Then flt = flt & " And [执行过程] Like \'%质保已收到%\'" Else If e.Form.Controls("RadioButton_质保收到_NO").Checked = True Then flt = flt & " And ([执行过程] Not Like \'%质保已收到%\' or [执行过程] is Null)" End If If e.Form.Controls("RadioButton_发票收到_YES").Checked = True Then flt = flt & " And [执行过程] Like \'%发票已收到%\'" Else If e.Form.Controls("RadioButton_发票收到_NO").Checked = True Then flt = flt & " And ([执行过程] Not Like \'%发票已收到%\' or [执行过程] is Null)" End If Tables("采购合同执行过程查询_Table_采购合同").Fill("Sel ect 合同号,签订日期,供应商,原产牌号,厚度,宽度,重量,单价,金额,付款方式,交货日期,提货方式,执行纪要 From {原料采购合同} Where" & flt,"ShcsErpSql",True)
|
-- 作者:大红袍 -- 发布时间:2015/7/7 16:09:00 -- 弹出 flt 看看。
1=1 不可能有问题 |
-- 作者:huangfanzi -- 发布时间:2015/7/8 9:03:00 -- 以下是上面代码的执行结果图: |
-- 作者:大红袍 -- 发布时间:2015/7/8 9:16:00 -- 你确定,去掉1=1 and 就正常? |
-- 作者:大红袍 -- 发布时间:2015/7/8 9:23:00 -- 是不是你这里少了空格?
Where " & flt |