Home » Fóruns » Database Administration and SQL Programming
 
Problem with SQL query? (113 visualizações)
Problem with SQL query? Postado em 05/07/2018 07:20 por sophiagrace526
I have the following SQL query but it is not working:
IF (SELECT * FROM members WHERE LIKE '%Ja%') > 1
BEGIN
SELECT * FROM members
END
GO

This is the error 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 (SELECT members.id FROM members) > 1 BEGIN SELECT * FROM members END GO LIMI' at line 1

Do you have any ideas?
Thanks In Advance
Update: I have corrected the if condition but I still get the same error and the query in the if condition does work as I have tested it. here is the updated query:
IF (SELECT * FROM members WHERE members.name LIKE '%Ja%') > 1
BEGIN
SELECT * FROM members
END
Update 2: Even this doesn't work:
IF (SELECT * FROM members WHERE members.name LIKE '%Ja%') > 1
THEN SELECT * FROM members

online web design

sophia / Logo Max

Problem with SQL query? (113 previews)
 
Home » Fóruns » Database Administration and SQL Programming