Trying to use IF EXISTS to automatically choose which table to select a record from.
I just get the following error message with the code below.
Where am I going wrong?
IF EXISTS (SELECT 1 FROM Users WHERE Reference='USR00000007')
SELECT * FROM Users WHERE Reference='USR00000007'
ELSE
SELECT * FROM Staff WHERE Reference='USR00000007';
Error: #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 EXISTS (SELECT 1 FROM Users WHERE Reference='USR00000007') SELECT * FROM' at line 1