0

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ''Nr_analizes' int NOT NULL, 'AnPacienti_id' int NOT NULL,

This is what I get when I run SQL code in mySQL. What is happening? The sintax looks fine to me.

CREATE TABLE Analiza_laboratorike(
'Nr_analizes' int NOT NULL,
'AnPacienti_id' int  NOT NULL,

 'Lloji_analizes' varchar(15) NOT NULL,
    'Kategoria_pacientit' varchar(15) NOT NULL,
    PRIMARY KEY(Nr_analizes),
    FOREIGN KEY(AnMjeku_id) REFERENCES Mjeku(Mjeku_id),
    Foreign KEY(AnPacienti_id) REFERENCES Pacienti(Pacienti_id))
1
  • 2
    You use the wrong TICKS ' use a backtick instead ` for the column name Commented Feb 13, 2016 at 20:56

2 Answers 2

1

Column or tables names shouldn't be enclosed in apostrophes:

CREATE TABLE Analiza_laboratorike(
Nr_analizes int NOT NULL,
AnPacienti_id int  NOT NULL,

Lloji_analizes varchar(15) NOT NULL,
Kategoria_pacientit varchar(15) NOT NULL,
PRIMARY KEY(Nr_analizes),
FOREIGN KEY(AnMjeku_id) REFERENCES Mjeku(Mjeku_id),
Foreign KEY(AnPacienti_id) REFERENCES Pacienti(Pacienti_id))
Sign up to request clarification or add additional context in comments.

Comments

1

Here the CREATE with back Ticks:

CREATE TABLE Analiza_laboratorike(
`Nr_analizes` INT NOT NULL,
`AnPacienti_id INT  NOT NULL,

 `Lloji_analizes` VARCHAR(15) NOT NULL,
    `Kategoria_pacientit` VARCHAR(15) NOT NULL,
    PRIMARY KEY(Nr_analizes),
    FOREIGN KEY(AnMjeku_id) REFERENCES Mjeku(Mjeku_id),
    FOREIGN KEY(AnPacienti_id) REFERENCES Pacienti(Pacienti_id))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.