MySQL Forums
Forum List  »  Newbie

1064 error on If statement in script
Posted by: Carl Reiff
Date: March 30, 2016 05:35PM

I have a VERY simple script. I've dumbed it way down:

Set @DisplayVal = 1;

If @DisplayVal = 1 Then
Select "Success";
End If;

When I execute it in the query analyzer I get: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'If @DisplayVal = 1 Then
Select "Success"' at line 1

This is with MySQL 5.5.32. For the life of me, I can't figure what could be wrong with this. I'm a SQL Server guy, but I'm writing an app for a customer who's ISP only offers MySQL. Does MySQL not allow If statements in scripts? From what I've read in the docs, it seems that it's supported in both scripts and stored procedures, but some comments I've seen on the web have indicated that it's only supported in SPs.

Options: ReplyQuote


Subject
Written By
Posted
1064 error on If statement in script
March 30, 2016 05:35PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.