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

  • SEARCH
  • Home
  • 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 8102869
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:21:24+00:00 2026-06-05T23:21:24+00:00

I am trying to create three tables however I am getting error as You

  • 0

I am trying to create three tables however I am getting error as

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 'REFERENCES personal_details(personID)
)'

The above error is for third table i.e. table hobbies_person.

I am creating tables as follow.

CREATE TABLE personal_details (
    personID   INT PRIMARY KEY,
    firstName  varchar(30),
    middleName varchar(30),
    lastName   varchar(30),
    age        INT,
    aboutMe    varchar(500)
);

CREATE TABLE hobbies (
    hobbID    INT PRIMARY KEY,
    hobbName  varchar(30)
);

CREATE TABLE hobbies_person (
    personID INT,
    hobbID   INT,
    PRIMARY KEY (personID, hobbID),
    FOREIGN KEY personID REFERENCES personal_details(personID)
);

I also tried with

CREATE TABLE hobbies_person (
    personID INT,
    hobbID   INT,
    PRIMARY KEY (personID, hobbID),
    FOREIGN KEY personID REFERENCES personal_details(personID),
    FOREIGN KEY hobbID   REFERENCES hobbies(hobbID)
);

but still same error.

Link to check query

Any idea how to tackle this?

NOTE

In table hobbies_person I am using composite primary key as PRIMARY KEY (personID, hobbID),

  • 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-06-05T23:21:28+00:00Added an answer on June 5, 2026 at 11:21 pm

    You forgot the () around your foreign key

    FOREIGN KEY (personID) REFERENCES personal_details(personID)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to create three controls that are layed out horizontally. In an
I'm trying to expect an error in an rspec test. lambda {Participant.create!({:user_id => three.id,
I'm trying to create an expression tree dynamicly. Let asume that I have two
I have a python script that is trying to create a directory tree dynamically
im trying to create a sql query, that will detect (possible) duplicate customers in
I'm trying to run the following query in SQL*Plus but I'm getting an error.
I have a MySQL Left Join problem. I have three tables which I'm trying
I'm trying to figure out the best way to create three 284x87 rounded rectangle
I am trying to create a UIAlertView with three buttons (which will be stacked).
I'm trying to create a small html fragment (a div element) consisted of three

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.