MySQL Forums
Forum List  »  Newbie

Insert if not exists MYSQL 5.5.24
Posted by: Leandro Rodrigues
Date: June 07, 2013 12:46PM

Hi,
I would like to make a query that allows me to enter data only if registration with aqueas conditions did not exist.

already tried this:
INSERT INTO descriptor
                          (texto_descritor, cod, codTipoDescritor, cod_Idioma)
VALUES ('Church of the Third', 1, 'tit', 'en')
WHERE (SELECT count (*) FROM descriptor WHERE cod = 1) = 0


And also:
INSERT INTO descriptor
                          (texto_descritor, cod, codTipoDescritor, cod_Idioma)
VALUES ('Church of the Third', 1, 'tit', 'en')
WHERE NOT EXISTS (SELECT * FROM descriptor WHERE cod = 1)

However none of these work.

Someone can help me?

Best Regards

Options: ReplyQuote


Subject
Written By
Posted
Insert if not exists MYSQL 5.5.24
June 07, 2013 12:46PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.