Welcome Guest, Not a member yet? Register   Sign In
Need Help with this Query

I'm writing a registration script and have run into a problem... my query syntax. My error:

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 'WHERE NOT EXISTS (SELECT * F' at line 3

INSERT INTO users (email, password, username) VALUES ('[email protected]', 'jesuit', 'test1') WHERE NOT EXISTS (SELECT * FROM users Where username = 'test1' LIMIT 1)

Any help will be greatly appreciated!

You insert query is incorrect. Try something:
INSERT INTO users(email,password,username)  SELECT 'test1','test','test1' FROM DUAL WHERE NOT EXISTS (SELECT * FROM users WHERE username='test1');

Thanks for your help. I ended up doing two separate queries to get what I wanted.

Theme © iAndrew 2016 - Forum software by © MyBB