Quantcast
Channel: MySQL Forums - Connector/J, JDBC and Java
Viewing all articles
Browse latest Browse all 884

Insert if exists (4 replies)

$
0
0
I'm trying to test my Java application. To accomplish this I run a script that should insert a test account in the database, if it not exists. If it exists, I want it to update fields (to the first values).

I tried it with:
INSERT INTO address 
 (perident, street, number, pcode, city, telephone, email, eori, iban )
(!) VALUES 
 ('jdoe', 'Fill in your own address information', NULL, NULL, NULL, NULL, NULL, NULL, NULL)
 ON DUPLICATE KEY UPDATE 
 	perident = 'jdoe', street = 'Fill in your own address information', number = NULL, pcode = NULL, city = NULL, 
 	telephone = NULL, email = NULL, eori = NULL, iban = NULL);

I get the error
#1064 - 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 ')' at line 2 (at the '(!) ')

Viewing all articles
Browse latest Browse all 884

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>