MySQL Forums
Forum List  »  MySQL Workbench

Error 1064: You have an error in your SQL syntax;
Posted by: souleymane Bamba
Date: April 18, 2022 02:46AM

I spent 2 hours trying to fix it but I couldn't find any solution
------- SQL SCRIPT -------------
-- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION';

-- -----------------------------------------------------
-- Schema mydb
-- -----------------------------------------------------
-- -----------------------------------------------------
-- Schema hospital_tess
-- -----------------------------------------------------

-- -----------------------------------------------------
-- Schema hospital_tess
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `hospital_tess` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ;
USE `hospital_tess` ;

-- -----------------------------------------------------
-- Table `hospital_tess`.`patient`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`patient` (
`patient_id` INT NOT NULL,
`patient_address` VARCHAR(45) NULL,
`patient_name` VARCHAR(45) NULL,
`patient_date_admitted` VARCHAR(45) NULL,
`patient_sex` VARCHAR(25) NULL,
PRIMARY KEY (`patient_id`))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8mb4
COLLATE = utf8mb4_0900_ai_ci;


-- -----------------------------------------------------
-- Table `hospital_tess`.`doctor`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`doctor` (
`doctor_id` INT NOT NULL,
`doctor_fname` VARCHAR(45) NULL,
`doctor_lname` VARCHAR(45) NULL,
`doctor_department` VARCHAR(45) NULL,
PRIMARY KEY (`doctor_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `hospital_tess`.`bill`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`bill` (
`bill_id` INT NOT NULL,
`bill_amount` DOUBLE NULL,
`bill_copay` DOUBLE NULL,
`bill_date_sent` VARCHAR(45) NULL,
`bill_status` VARCHAR(45) NULL,
PRIMARY KEY (`bill_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `hospital_tess`.`Visit`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`Visit` (
`visit_id` INT NOT NULL,
`patient_id` INT NULL,
`doctor_id` INT NULL,
`bill_id` INT NOT NULL,
PRIMARY KEY (`visit_id`, `bill_id`),
INDEX `fk_Visit_bill1_idx` (`bill_id` ASC) INVISIBLE,
CONSTRAINT `patient_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`patient` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `doctor_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`doctor` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Visit_bill1`
FOREIGN KEY (`bill_id`)
REFERENCES `hospital_tess`.`bill` (`bill_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `hospital_tess`.`insurance`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`insurance` (
`ins_id` INT NOT NULL,
`ins_name` VARCHAR(45) NULL,
`ins_phone` INT NULL,
PRIMARY KEY (`ins_id`))
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `hospital_tess`.`payment`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`payment` (
`pay_id` INT NOT NULL,
`pay_date` DATETIME NULL,
`pay_method` VARCHAR(45) NULL,
PRIMARY KEY (`pay_id`),
CONSTRAINT `bill_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`bill` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `patient_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`patient` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `ins_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`insurance` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;





--------****-*-*-*--*-*-*-*-*-*--*-*-*-*-*--*-*--*-*-*-*-*-ERROR Log --------****-*-*-*--*-*-*-*-*-*--*-*-*-*-*--*-*--*-*-*-*-*-
Executing SQL script in server
ERROR: Error 1064: 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 ')
REFERENCES `hospital_tess`.`patient` ()
ON DELETE NO ACTION
ON UPD' at line 12
SQL Code:
-- -----------------------------------------------------
-- Table `hospital_tess`.`Visit`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `hospital_tess`.`Visit` (
`visit_id` INT NOT NULL,
`patient_id` INT NULL,
`doctor_id` INT NULL,
`bill_id` INT NOT NULL,
PRIMARY KEY (`visit_id`, `bill_id`),
INDEX `fk_Visit_bill1_idx` (`bill_id` ASC) INVISIBLE,
CONSTRAINT `patient_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`patient` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `doctor_id`
FOREIGN KEY ()
REFERENCES `hospital_tess`.`doctor` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_Visit_bill1`
FOREIGN KEY (`bill_id`)
REFERENCES `hospital_tess`.`bill` (`bill_id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB

SQL script execution finished: statements: 8 succeeded, 1 failed

Fetching back view definitions in final form.
Nothing to fetch

Options: ReplyQuote


Subject
Views
Written By
Posted
Error 1064: You have an error in your SQL syntax;
435
April 18, 2022 02:46AM


Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.