Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7443099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:16:45+00:00 2026-05-29T11:16:45+00:00

Im currently writing a database for a school project. Im using MySQL on xampp

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T11:16:45+00:00Added an answer on May 29, 2026 at 11:16 am

    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.

    use stackoverflow;
    
    create table if not exists stackoverflow.product
    (
        product_id int not null auto_increment,
        name varchar(80) not null,
        primary key(product_id)
    );
    
    create table if not exists stackoverflow.category
    (
        category_id int not null auto_increment,
        name varchar(80) not null,
        primary key(category_id)
    );
    
    create table if not exists stackoverflow.product_category
    (
        product_id int,
        category_id int,
        primary key(product_id, category_id),
        constraint product_id_fkey
            foreign key(product_id) references product(product_id)
            on delete cascade
            on update no action,
        constraint category_id_fkey
            foreign key(category_id) references category(category_id)
            on delete cascade
            on update no action
    );
    
    insert into stackoverflow.product(name) values('teddy bear');
    insert into stackoverflow.category(name) values('toy');
    insert into stackoverflow.product_category
        select p.product_id, c.category_id from product as p, category as c
        where p.name = 'teddy bear' and c.name = 'toy';
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently writing a Java app that interfaces with a MySQL database. My problem
I am currently writing a java-class that wraps an SQLite database. This class has
I'm currently writing the documentation for a database using berkeleyDB. I'd like to draw
I am currently re-writing a dynamic form based on database information. This form contains
I'm currently writing a class to handle all database-activity in my application, and so
I'm currently writing a PHP application and drivers (classes) for the database engines. I
I'm currently writing a C#-class in my ASP.NET (3.5) application to handle all database-queries.
I'm currently writing a website in ASP.NET MVC, and my database (which doesn't have
Im currently writing my bachelor thesis with latex and using TexnicCenter. I want to
I am currently writing a script that intelligently strips a database down into a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.