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

[eluser]mlage[/eluser]
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!
#2

[eluser]mah0001[/eluser]
You insert query is incorrect. Try something:
Code:
INSERT INTO users(email,password,username)  SELECT 'test1','test','test1' FROM DUAL WHERE NOT EXISTS (SELECT * FROM users WHERE username='test1');
#3

[eluser]mlage[/eluser]
Thanks for your help. I ended up doing two separate queries to get what I wanted.




Theme © iAndrew 2016 - Forum software by © MyBB