IF is not valid in this position

I checked / compared the SQL statement several times, but it still doesn't work. I am using WorkBench 6.3 with MySQL. This gives me an error:

Syntax Error 1064: "IF" is not a valid input at this position.

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; 
+5
source share
1 answer

You cannot use IF in an SQL statement. It can only be used in a stored procedure or function.

You can rewrite your expression as follows:

 SELECT TimeUploaded from RECORDS WHERE FORMID = 200002016 AND TimeUploaded > '2016-07-17 03:13:39' AND TimeUploaded < '2016-07-17 03:13:39' 
+5
source

All Articles