INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Pls help with diagnosing this insert/update statement?

Pls help with diagnosing this insert/update statement?

Pls help with diagnosing this insert/update statement?

(OP)
Ever run into a brick wall. This (seemingly) simple sql statement is failing with a syntax error. I've checked field names against the table definitions and they look to be exact. The content of the data is also as expected. I've searched for samples and what I find all appear similar to what I have. So would someone please point out where the syntax might be in error? btw I'm using 5.5.44 and this must run on MariaDB as well. Any pointers - THANKS!

INSERT INTO alminfo_mbsaqip.patients ( id, mbsaqip_case_number, acs_nsqip_case_number, idn, firstname, lastname )
VALUES ( '5', '01234', '54321', '56789', 'Leslie', 'Liverpool' )
ON DUPLICATE KEY UPDATE mbsaqip_case_number = '01234', acs_nsqip_case_number = '54321',
idn = '56789', firstname = 'Leslie', lastname = 'Liverpool' WHERE id = '5';

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 'WHERE id = '5'' at line 4

I've also tried it without the WHERE on the update seeing how its a duplicate anyway. Same error message pointing to an earlier place in the statement.

Here's the definition:

CREATE TABLE IF NOT EXISTS `alminfo_mbsaqip`.`patients` (
`id` INT NOT NULL,
`mbsaqip_case_number` VARCHAR(45) NULL,
`acs_nsqip_case_number` VARCHAR(45) NULL,
`idn` VARCHAR(45) NULL,
`firstname` VARCHAR(45) NULL,
`lastname` VARCHAR(45) NULL,
`assessment_date` DATE NULL,
`patient_alive` INT NULL,
`exam_by_bariatric_physician_or_pa_np` INT NULL,
`seen_by_clinician` INT NULL,
`sleep_apnea` VARCHAR(45) NULL,
`gerd_req_meds` VARCHAR(45) NULL,
`hyperlipidemia` VARCHAR(45) NULL,
`hypertension` VARCHAR(45) NULL,
`diabetes` VARCHAR(45) NULL,
`follow_up_noshow` VARCHAR(45) NULL,
`phone_call_placed` VARCHAR(45) NULL,
`letter_sent` VARCHAR(45) NULL,
`transfer_to_specalist` VARCHAR(45) NULL,
`patient_refuse_long_term_fu` INT NULL,
`lost_to_follow_up` INT NULL,
`date_of_death` DATE NULL,
`death_related_to_operation` INT NULL,
`cause_of_death` VARCHAR(45) NULL,
`comments` MEDIUMTEXT NULL,
`timestamp` VARCHAR(45) NULL,
`surgeon` VARCHAR(45) NULL,
`surgery_date` VARCHAR(45) NULL,
`facility` VARCHAR(45) NULL,
`alm_patient_id` VARCHAR(45) NULL,
`procedure` VARCHAR(45) NULL,
`comment` MEDIUMTEXT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB;

RE: Pls help with diagnosing this insert/update statement?

Hi

Quote (BobMCT)

I've also tried it without the WHERE on the update
Insist on that. There is no where clause for on duplicate key update. Without where your code works fine for me on MySQL 5.6.28.

Feherke.
feherke.ga

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close