multi-column key with "ON DUPLICATE KEY UPDATE"

This is a discussion on multi-column key with "ON DUPLICATE KEY UPDATE" within the MySQL Database forums, part of the Database Forums category; Hi guys, Been trying to use ON DUPLICATE KEY UPDATE on a MyISAM table with a multi-column primary key, ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 12-20-2007
jezaustin@gmail.com
 
Posts: n/a
Default multi-column key with "ON DUPLICATE KEY UPDATE"

Hi guys,
Been trying to use ON DUPLICATE KEY UPDATE on a MyISAM table with a
multi-column primary key, and I keep getting a syntax error message.
eg

INSERT INTO contacts_extra (contact_id, keyword, value)
VALUES (1, '10/Primary food activity', '2')
ON DUPLICATE KEY UPDATE `value`='2';

on a table like
CREATE TABLE `contacts_extra` (
`contact_id` INT UNSIGNED NOT NULL
,`keyword` VARCHAR(63) NOT NULL
,`value` VARCHAR(255) NOT NULL
,PRIMARY KEY (`contact_id`, `keyword`)
) TYPE=MyISAM;

Is there something special about multi-column keys that prevents on
duplicate key update from working? Or have I really made a silly
syntax error?

Thanks,
J.
Reply With Quote
  #2 (permalink)  
Old 12-20-2007
Rik Wasmus
 
Posts: n/a
Default Re: multi-column key with "ON DUPLICATE KEY UPDATE"

On Thu, 20 Dec 2007 15:23:12 +0100, <jezaustin@gmail.com> wrote:

> Hi guys,
> Been trying to use ON DUPLICATE KEY UPDATE on a MyISAM table with a
> multi-column primary key, and I keep getting a syntax error message.
> eg
>
> INSERT INTO contacts_extra (contact_id, keyword, value)
> VALUES (1, '10/Primary food activity', '2')
> ON DUPLICATE KEY UPDATE `value`='2';
>
> on a table like
> CREATE TABLE `contacts_extra` (
> `contact_id` INT UNSIGNED NOT NULL
> ,`keyword` VARCHAR(63) NOT NULL
> ,`value` VARCHAR(255) NOT NULL
> ,PRIMARY KEY (`contact_id`, `keyword`)
> ) TYPE=MyISAM;
>
> Is there something special about multi-column keys that prevents on
> duplicate key update from working? Or have I really made a silly
> syntax error?


...works perfectly here? Are you sure that is the exact query you enter,
and if so, what is the actual error you're getting?
--
Rik Wasmus
Reply With Quote
  #3 (permalink)  
Old 12-20-2007
Paul Lautman
 
Posts: n/a
Default Re: multi-column key with "ON DUPLICATE KEY UPDATE"

jezaustin@gmail.com wrote:
> Hi guys,
> Been trying to use ON DUPLICATE KEY UPDATE on a MyISAM table with a
> multi-column primary key, and I keep getting a syntax error message.
> eg
>
> INSERT INTO contacts_extra (contact_id, keyword, value)
> VALUES (1, '10/Primary food activity', '2')
> ON DUPLICATE KEY UPDATE `value`='2';
>
> on a table like
> CREATE TABLE `contacts_extra` (
> `contact_id` INT UNSIGNED NOT NULL
> ,`keyword` VARCHAR(63) NOT NULL
> ,`value` VARCHAR(255) NOT NULL
> ,PRIMARY KEY (`contact_id`, `keyword`)
> ) TYPE=MyISAM;
>


This is not the promised example of the syntax error message.

If you post the EXACT error message that you are getting, maybe we can help
you!



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 01:33 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0