datetime between case when @timeStart='' and @timeEnd='' then datetime else @timeStartand and @timeEndend end 关键字 'and' 附近有语法错误。为什么提示我and附近有语法错误 我想写的是:当timeStart和timeEnd这2个参数不为空时,就查找datetime符合这2个条件中的数据
datetime between case when @timeStart='' and @timeEnd='' then datetime else @timeStart and @timeEnd end为什么提示我and附近有语法错误 我想写的是:当timeStart和timeEnd这2个参数不为空时,就查找datetime符合这2个条件中的数据
case when只能返回固定的值类型,而你返回的是句子,就不对了~ 这种判断只能用if提前判断,然后整个语句复写一遍 或者是用if判断后,在@time的参数赋值上进行改动
试试:[datetime] BETWEEN CASE WHEN @timeStart='' and @timeEnd='' THEN [datetime] ELSE @timeStartand END AND @timeEndend
datetime between case when @timeStart='' and @timeEnd=''
then datetime else @timeStart and @timeEnd end为什么提示我and附近有语法错误
我想写的是:当timeStart和timeEnd这2个参数不为空时,就查找datetime符合这2个条件中的数据
这种判断只能用if提前判断,然后整个语句复写一遍
或者是用if判断后,在@time的参数赋值上进行改动