MySQL Forums
Forum List  »  Stored Procedures

If exist Update else insert query
Posted by: wasim ahmad
Date: December 07, 2020 01:33AM

SELECT IF (EXISTS(
SELECT * FROM Terminal WHERE IP_address=10.40.186.7))
UPDATE terminals SET IP_address=10.40.186.7 WHERE ID=1 and Name='anshu'
ELSE
INSERT INTO Terminal (ID, type_ID, Name,IP_address,tags,create_access_ID,Status_ID)
VALUES (`Id`, `type_ID`,`anshu`,`10.40.192.88`,`Registery`,`a59660306a0e1e`,`0`);


ABOVE QUERY NOT WORKING IN MYSQL 8.0
FOLLOWING ERROR OCCURRED
ERROR 1064 (42000): 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 '.186.7))

Options: ReplyQuote


Subject
Views
Written By
Posted
If exist Update else insert query
1203
December 07, 2020 01:33AM


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.