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));

closed as off-topic by ypercubeᵀᴹ, Michael Green, billinkc, Philᵀᴹ, Mark Sinkinson Aug 3 '16 at 8:15

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – ypercubeᵀᴹ, Michael Green, billinkc, Philᵀᴹ, Mark Sinkinson
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 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));

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