I am trying to execute the following query:

INSERT INTO table_listnames (name, address, tele)
VALUES ('Rupert', 'Somewhere', '022')
WHERE NOT EXISTS (
    SELECT name FROM table_listnames WHERE name="value"
);

But this returns an error. Basically I don’t want to insert a record if the ‘name’ field of the record already exists in another record – how to check if the new name is unique?

16 Answers
16

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *