Im currently writing a database for a school project. Im using MySQL on xampp and trying to add this table to my database. Im still not 100% on my SQL syntax and theres an error here I cannot seem ti figure out:
CREATE TABLE photoDB(
U_id INT UNSIGNED NOT NULL FOREIGN KEY REFERENCES userDB(U_id),
P_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
C_id INT UNSIGNED NOT NULL FOREIGN KEY REFERENCES table_comments(C_id),
PhotoName VARCHAR(50),
Description TEXT NOT NULL,
File VARCHAR,
Views BIGINT UNSIGNED,
Rep DOUBLE (100000, 2),
UploadDate DATETIME,
EditDate DATETIME,
EditVersion INT UNSIGNED,
LatestEditVerion INT UNSIGNED
);
Im having the same issue with all of the tables Im trying to create.
Heres the error message:
#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 'FOREIGN KEY REFERENCES userDB(U_id), P_id INT UNSIGNED NOT NULL AUTO_INCREMENT ' at line 2
Thanks in advance
The previous answers are true. You’ve got other problems, too (e.g. you can’t have a DOUBLE that big; max = 255).
You’ve got issues, man.
Here’s a simple example that perhaps you can extend. It has two tables with a many-to-many relationship between them. The join table has two foreign keys. It works in MySQL – I just created a database and added these tables.