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;
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;