我已经检查/比较了SQL语句几次,但它仍然不起作用。我正在使用带有MySQL的Workbench6.3。它给了我一个错误:
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;
不能在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'