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 6763415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:28:24+00:00 2026-05-26T14:28:24+00:00

having an issue getting this to work. MySQL keeps throwing the following: ERROR 1064

  • 0

having an issue getting this to work. MySQL keeps throwing the following:

ERROR 1064 (42000): 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 'ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (order_id) REFERENCES order' at line 6

And the SQL is:

DROP TABLE IF EXISTS `user_orders`;
CREATE TABLE `user_orders` (
`user_orders_user_id` int(10) unsigned NOT NULL default '0',
`user_orders_order_id` int(10) unsigned NOT NULL default '0',
PRIMARY KEY (`user_orders_user_id`, `user_orders_order_id`),
FOREIGN KEY (user_id) REFERENCES user(id),
    ON DELETE CASCADE ON UPDATE CASCADE,
FOREIGN KEY (order_id) REFERENCES order(id)
    ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB;

user_orders acts as an intermediate table for User.id and Order.id (i.e. holds a record for each order made by a user). I feel like I’m missing something obvious. The User table has no FK’s and the Order table has an FK (user_id) to User.id (with ON DELETE CASCADE ON UPDATE CASCADE).

Hopefully I’m just tired and it’s a minor syntax issue…

  • 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-26T14:28:25+00:00Added an answer on May 26, 2026 at 2:28 pm

    You have a comma that should not be there on this line:

    FOREIGN KEY (user_id) REFERENCES user(id),
    

    Besides, in your table you have not field such as user_id and order_id. Infact you have user_orders_user_id and user_orders_order_id

    Besides, you have to include the order between the ' because is a reserved word as suggested by ypercube.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue getting a LINQ query to work. I have this XML:
I'm having an issue getting the following syntax to work: <rewriter> <!-- This does
I'm having an issue getting this CSS for a sprite sheet to work on
Im having issues getting this to work, maybe its not even possible? I have
I am having a little trouble getting this to work. I have several anchor
i am having trouble getting this to work, can any one spot the issue?
I am having an issue getting this to work. On our form we validate
I'm having an issue getting this jQuery.ajax call to work. When the script executes
I am getting into C# and I am having this issue: namespace MyDataLayer {
I'm having an issue getting some code to work. Is there a way to

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.