enxhi bregu
enxhi bregu

Reputation: 1

MySQL MariaDB syntax error

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

Upvotes: 0

Views: 1927

Answers (2)

Bernd Buffen
Bernd Buffen

Reputation: 15057

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

Upvotes: 1

Zbynek Vyskovsky - kvr000
Zbynek Vyskovsky - kvr000

Reputation: 18825

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

Upvotes: 1

Related Questions