I am trying to use a subquery to avoid duplicate entries when someone submits a form to subscribe to a mailing list.
So I want to check if the email exists before adding the record.
I tried something like:
Expand|Select|Wrap|Line Numbers
- INSERT INTO mailing_list (ID,Email) VALUES ('','$Email') WHERE NOT EXISTS (SELECT * FROM mailing_list WHERE Email LIKE '$Email'')
I can just "give up" and run two queries, the first to look for the email and the second to enter the email if it does not already exist; I just want to start being more efficient and using subqueries. Thanks for any advice!!!