I have created a very basic database in 'MySQL Workbench' just as a test..
This is the SQL it produced -
CREATE TABLE IF NOT EXISTS `CustomerOrder` (
`OrderID` INT NOT NULL AUTO_INCREMENT ,
`OrderDate` VARCHAR(45) NOT NULL ,
`ProductName` VARCHAR(70) NOT NULL ,
`ProductCost` VARCHAR(45) NOT NULL ,
PRIMARY KEY (`OrderID`) ,
INDEX `UserID` () ,
CONSTRAINT `UserID`
FOREIGN KEY ()
REFERENCES `Users` ()
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = MyISAM
When I copy it into phpmyadmin it does not let me turn it into a table.
This is the error message I get;
Error
SQL query:
CREATE TABLE IF NOT EXISTS `CustomerOrder` (
`OrderID` INT NOT NULL AUTO_INCREMENT ,
`OrderDate` VARCHAR( 45 ) NOT NULL ,
`ProductName` VARCHAR( 70 ) NOT NULL ,
`ProductCost` VARCHAR( 45 ) NOT NULL ,
PRIMARY KEY ( `OrderID` ) ,
INDEX `UserID` ( ) ,
CONSTRAINT `UserID` FOREIGN KEY ( ) REFERENCES `Users` ( ) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = MyISAMCREATE TABLE IF NOT EXISTS `CustomerOrder` (
`OrderID` INT NOT NULL AUTO_INCREMENT ,
`OrderDate` VARCHAR( 45 ) NOT NULL ,
`ProductName` VARCHAR( 70 ) NOT NULL ,
`ProductCost` VARCHAR( 45 ) NOT NULL ,
PRIMARY KEY ( `OrderID` ) ,
INDEX `UserID` ( ) ,
CONSTRAINT `UserID` FOREIGN KEY ( ) REFERENCES `Users` ( ) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE = MYISAM
MySQL said:
#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 ') , CONSTRAINT `UserID` FOREIGN KEY () REFERENCES `Users` () ON DELETE' at line 1
Thanks in advance.