我已多次检查/比较SQL语句,但它仍然无效。我正在使用WorkBench 6.3和MySQL。它给了我一个错误:
1064语法错误:' IF'在这个位置不是有效的输入。
IF(EXISTS(SELECT * FROM RECORDS WHERE FORMID = 200002016 AND TimeUploaded > '2016-07-17 03:13:39' AND TimeUploaded < '2016-07-17 03:13:39'))
Begin
SELECT TimeUploaded from RECORDS
End;
答案 0 :(得分:7)
您不能在SQL语句中使用IF
。您只能在存储过程或函数中使用它。
你可以像这样重写你的陈述:
SELECT TimeUploaded from RECORDS
WHERE FORMID = 200002016
AND TimeUploaded > '2016-07-17 03:13:39'
AND TimeUploaded < '2016-07-17 03:13:39'