Problems with SQL statement, on duplicate key update

Hello!

I am trying to update a record or insert it if it does not exist but I am having a hard time doing it and I can´t find where the problem is, can someone help me out and point me in the right direction


INSERT INTO `jml_fl_users`
	(
		`id`,
		`street`,
		`town`,
		`city`,
		`state`,
		`country`,
		`zipcode`,
		`coordinates`,
		`phone`,
		`website`,
		`favoritebook`,
		`aboutme`,
		`birthdate`
	)
	VALUES(
		54,
		'200 Cisnes',
		'Lago de Guadalupe',
		'Cuautitlán Izcalli',
		'Mexico',
		'Mexico',
		'54760',
		'19.6285952093597,-99.25037122265627',
		'6148356117',
		'http://www.tlacaelelrl.com',
		'gttry',
		'rtyrty',
		'1983-01-04'
	)
	ON DUPLICATE KEY UPDATE
	SET street = '200 Cisnes',
	town = 'Lago de Guadalupe',
	city = 'Cuautitlan Izcalli',
	state = 'Mexico',
	country = 'Mexico',
	zipcode = '54760',
	coordinates = '19.6285952093597,-99.25037122265627',
	phone = '6148356117',
	website = 'http://www.tlacaelelrl.com',
	favoritebook = 'gttry',
	aboutme = 'gttry',
	birthdate = '1983-01-04'
	WHERE
	id = 54;

why not do the check first.

If Not Exists(select (1) from …Where…)
Insert into …

you know, you really should become friends wif da manual

look up the INSERT statement for the correct syntax

here, i’ll help you this time… http://dev.mysql.com/doc/refman/5.1/en/insert.html

there is no SET keyword allowed in the ON DUPLICATE KEY clause, and no WHERE clause either

:slight_smile: