-1

I ' m creating composite primary key for my web site but it occurs some error code 1064... I tried but ...i did not Rectify that error ....so i m posting my question here... please suggest what changes should i do .....my tables are below

DROP TABLE IF EXISTS `tbl_doctor_hospital`;

CREATE TABLE
   `tbl_doctor_hospital`
   (
      `fld_d_h_id`               INT(11) NOT NULL AUTO_INCREMENT
    , `fld_doctor_id`            INT(11) DEFAULT NULL
    , `fld_hospital_id`          INT(11) DEFAULT NULL
    , `fld_consultation_General` DECIMAL(12,2) DEFAULT NULL
    , `fld_consultation_Private` DECIMAL(12,2) DEFAULT NULL
    , `fld_Visttime_From`        VARCHAR (10) DEFAULT NULL
    ,
      /*store in time format with AM/PM*/
      `fld_Visttime_To` VARCHAR (10) DEFAULT NULL
    ,
      /*store in time format with AM/PM*/
      `fld_added_date`  datetime DEFAULT NULL
    , `fld_update_date` datetime DEFAULT NULL
    , PRIMARY KEY (`fld_d_h_id`,`fld_doctor_id`,`fld_hospital_id`)
    , FOREIGN KEY (`fld_doctor_id`) REFERENCES tbl_doctor (`fld_doctor_id` )
      FOREIGN KEY (`fld_hospital_id`) REFERENCES tbl_hospital (`fld_hospital_id` )
   )
   ENGINE=InnoDB DEFAULT CHARSET=latin1;

---------------------------------------------------------------------------

DROP TABLE
   IF EXISTS `tbl_equipment_supplier` ;

CREATE TABLE
   `tbl_equipment_supplier`
   (
      `fld_e_s_id`       INT(11) NOT NULL AUTO_INCREMENT
    , `fld_equipment_id` INT(11) NOT NULL
    , `fld_supplier_id`  INT(11) DEFAULT NULL
    , `fld_currency`     VARCHAR (5) DEFAULT NULL
    ,
      /*INR / USD / EURO / UKP*/
      `fld_equipment_price` DECIMAL(11,2) DEFAULT NULL
    , `fld_deliverydays`    INT(3) DEFAULT NULL
    , `fld_terms` text DEFAULT NULL
    , `fld_added_date`  datetime DEFAULT NULL
    , `fld_update_date` datetime DEFAULT NULL
    , PRIMARY KEY (`fld_e_s_id`,`fld_equipment_id` ,`fld_supplier_id`)
    , FOREIGN KEY (`fld_equipment_id`) REFERENCES tbl_equipment (`fld_equipment_id` ) 
      FOREIGN KEY (`fld_supplier_id`) REFERENCES tbl_supplier (`fld_supplier_id` )
   )
   ENGINE=InnoDB DEFAULT CHARSET=latin1;
dnoeth
  • 59,503
  • 4
  • 39
  • 56
  • possible duplicate of [How can I fix MySQL error #1064?](http://stackoverflow.com/questions/23515347/how-can-i-fix-mysql-error-1064) – eggyal May 10 '14 at 17:26

1 Answers1

0

After applying some proper formatting it's easy to spot the missing comma before the 2nd Foreign Key.

dnoeth
  • 59,503
  • 4
  • 39
  • 56