1

I'm trying to create a data base, but I get this error:

ERROR 1064 (42000) at line 37: 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 Users_Manager_ID_PK PRIMARY KEY(Manager_ID, Employee_ID))' at line 6

CREATE TABLE Customer
(
Customer_ID INTEGER(8) PRIMARY KEY,
f_Name VARCHAR(25) NOT NULL,
l_Name VARCHAR(25) NOT NULL);

CREATE TABLE Users
(
Manager_ID INTEGER(8) NOT NULL,
Employee_ID INTEGER(8) NOT NULL,
f_Name VARCHAR(25) NOT NULL,
l_Name VARCHAR(25) NOT NULL),
CONSTRAINT Users_Manager_ID_PK PRIMARY KEY(Manager_ID, Employee_ID));


CREATE TABLE Advertising 
(
Sales_Person VARCHAR(25) PRIMARY KEY,
CONSTRAINT Advertising_Manager_ID_FK FOREIGN KEY(Manager_ID) REFERENCES Users(Manager_ID)),
CONSTRAINT Advertising_Employee_ID_FK FOREIGN KEY(Employee_ID) REFERENCES Users(Employee_ID));
  • 2
    You have a closing parenthesis, just before the CONSTRAINT Users_Manager_ID_PK. Remove that parenthesis. – ypercubeᵀᴹ Aug 2 '16 at 20:04
0
CREATE TABLE Customer ( Customer_ID INTEGER(8) PRIMARY KEY, f_Name VARCHAR(25) NOT NULL, l_Name VARCHAR(25) NOT NULL);

CREATE TABLE Users ( Manager_ID INTEGER(8) NOT NULL, Employee_ID INTEGER(8) NOT NULL, f_Name VARCHAR(25) NOT NULL, l_Name VARCHAR(25) NOT NULL,
    CONSTRAINT Users_Manager_ID_PK PRIMARY KEY(Manager_ID, Employee_ID),
    CONSTRAINT idx_unque_users UNIQUE KEY (Employee_ID,Manager_ID));

CREATE TABLE Advertising ( Sales_Person VARCHAR(25) PRIMARY KEY, Manager_ID INTEGER(8) NOT NULL,Employee_ID INTEGER(8) NOT NULL,
    CONSTRAINT Advertising_Manager_ID_FK FOREIGN KEY (Manager_ID) REFERENCES Users(Manager_ID), 
    CONSTRAINT Advertising_Employee_ID_FK FOREIGN KEY (Employee_ID) REFERENCES Users(Employee_ID));
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.