我试图在phpMyAdmin中执行查询,但这给我一个错误,说:


  1064-您的SQL语法有误;检查手册
  对应于您的MySQL服务器版本以使用正确的语法
  ')附近
      参考Online ShoppingCustomer()
      不删除任何动作
      '在第11行


查询是:

CREATE  TABLE IF NOT EXISTS `Online Shopping`.`Order_Details` (
  `Order_Id` INT NOT NULL ,
  `Product_Name` VARCHAR(45) NULL ,
  `Price_For_Each_Product` VARCHAR(45) NULL ,
  `No_of_Product_ordered` VARCHAR(45) NULL ,
  `Ordered_Date` DATE NULL ,
  `Total_Price` VARCHAR(45) NULL ,
  `Generated_Key` VARCHAR(45) NULL ,
  PRIMARY KEY (`Order_Id`) ,
  CONSTRAINT `Customer_Id`
    FOREIGN KEY ()
    REFERENCES `Online Shopping`.`Customer` ()
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `Order_LineId`
    FOREIGN KEY ()
    REFERENCES `Online Shopping`.`Order_Line` ()
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

最佳答案

CREATE  TABLE IF NOT EXISTS `Online Shopping`.`Order_Details` (
  `Order_Id` INT NOT NULL PRIMARY KEY AUTO_INCREMENT ,
  `Product_Name` VARCHAR(45) NULL ,
  `Price_For_Each_Product` VARCHAR(45) NULL ,
  `No_of_Product_ordered` VARCHAR(45) NULL ,
  `Ordered_Date` DATE NULL ,
  `Total_Price` VARCHAR(45) NULL ,
  `Generated_Key` VARCHAR(45) NULL,
  CONSTRAINT `Customer_Id`
    FOREIGN KEY (Customer_ID)
    REFERENCES `Online Shopping`(Customer)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `Order_LineId`
    FOREIGN KEY (Customer_ID)
    REFERENCES `Online Shopping`(Order_Line)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;

09-25 22:13