Skip to content
Advertisement

This script won’t run on PHPmyadmin. Neither will any others [closed]

When trying to run this script or any script on PHPmyadmin, it shows the same error, can anyone help?

CREATE DATABASE IF NOT EXISTS Project

CREATE TABLE Customers (
Customer_Email varchar(50) NOT NULL,
Customer_Firstname varchar(50) NOT NULL,
Customer_Lastname varchar(50) NOT NULL,
Customer_House_No_Name varchar(40) NULL,
Customer_Post_Code varchar(10) NULL,
Customer_City varchar(50) NULL,
PRIMARY KEY (Customer_mail)
);

CREATE TABLE Services (
Service_Name varchar(40) NOT NULL,
Service_Description text NOT NULL,
Service_Price decimal(7,2) NOT NULL,
PRIMARY KEY (Service-Name)
);

CREATE TABLE Orders (
Customer_Email varchar(50) NOT NULL FOREIGN KEY REFERENCES Customers(Customer_Email),
Order_Date_Time DATETIME NOT NULL DEFAULT GETDATE(),
Staff_Email varchar(50) NOT NULL FOREIGN KEY REFERENCES Staff(Staff_Email),
PRIMARY KEY (Customer_Email, Order_Date_Time),
);


CREATE TABLE Staff (
Staff_Email varchar(50) NOT NULL,
Staff_Firstname varchar(50) NOT NULL,
Staff_Lastname varchar(50) NOT NULL,
PRIMARY KEY (Staff_Email)
);

CREATE TABLE Order_Details (
Customer_Email varchar(50) NOT NULL FOREIGN KEY REFERENCES Customers(Customer_Email),
Order_Date_Time DATETIME NOT NULL DEFAULT GETDATE() FOREIGN KEY REFERENCING Orders(Order_Date_Time),
Service_Name varchar(40) NOT NULL FOREIGN KEY REFERENCING Services(Service_Name),
Service_Ordered_Price DECIMAL NOT NULL FOREIGN KEY REFERENCES Services(Service_Price),
Discount Decimal(5,2) NULL,
Quantity int(6) NOT NULL, 
PRIMARY KEY (Customer_Email, Order_Date_Time, Service_Name)
);

My Error :

MySQL said: Documentation

#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 ‘CREATE TABLE Customers ( Customer_Email varchar(50) NOT NULL, Customer_Firstna’ at line 3

Advertisement

Answer

CREATE DATABASE IF NOT EXISTS Project is missing the final semicolon.
It should be CREATE DATABASE IF NOT EXISTS Project;

Naturally the error returned is on the next line because the syntax, at that point, becomes wrong.
In general when you receive an error about SQL syntax, not only check given rows but even the ones before.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement