in reply to Re^2: MySQL syntax error for ON DUPLICATE KEY UPDATE
in thread MySQL syntax error for ON DUPLICATE KEY UPDATE
Alternatively, you can refer to the values in the insert part with the values() function:
So your statement string would be:insert into foo (bar, baz) values (?, ?) on duplicate key update bar = values(bar) , baz = values(baz)
my $stmt = 'INSERT INTO contact_form (' . join(',', keys %sql) . ') VALUES (' . join(',', ('?') x keys %sql) . ') ON DUPLICATE KEY UPDATE '. join(', ', map { "$_ = values($ +_)" } keys %sql);
|
---|
In Section
Seekers of Perl Wisdom