First off I know this is a duplicate however I've tried multiple different question's answers and none have worked for me. Here is my code:
IF EXISTS (SELECT * FROM user='username') select 1 else select 0
My database is set up like each account is its own column, so there is a table filled with user account rows. I don't know if that was the professional way to do it. So suggestions would be helpful and appreciated.
Here is the phpMyAdmin error: (Very unhelpful)
SQL query: Documentation
IF NOT EXISTS (
SELECT *
FROM user = '*'
)
SELECT 1
ELSE SELECT 0
MySQL said: Documentation
#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 not EXISTS (SELECT * FROM user='*') select 1 else select 0' at line 1
Your snippet
IF EXISTS (SELECT * FROM user='username') select 1 else select 0
is no valid SQL.
Assuming you want to count all entries in the table called 'user' with the user name "johndoe", and the name of the user resides in the column called 'username', you would write the following:
SELECT COUNT(*) FROM USER WHERE USERNAME='johndoe';
For further reading: http://dev.mysql.com/doc/refman/5.6/en/select.html