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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T07:48:22+00:00 2026-05-21T07:48:22+00:00

I hope some one more SQL wise can help me. Suppose the following table

  • 0

I hope some one more SQL wise can help me. Suppose the following table and relationships they’re compacted.


orders(PK_refno,customer, status)
order_accessories(PK_refno,PK_acc)
accessories(PK_acc,name,desc)

As you can see this is a typical 1:*----*:*----*:1 scenario the the issue or my concern is when updating, as the accessories that each order has can be modified, meaning that an user can add/remove accessories.

The only way I’ve thought to do it by using MySQL is to delete all accessories and then insert the updated ones.

I dislike it this way. As I think that probably there’s a SQL way to do it. Maybe someone can suggest and advanced query (which I’ll study of course)

The other way I thought was to:

  • Retrieve the originals.
  • Compare them and remove/add the differences.

    I’m not a fan of this either because it would be done in the app, not in the database.

    • 1 1 Answer
    • 1 View
    • 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-21T07:48:23+00:00Added an answer on May 21, 2026 at 7:48 am

      Let’s say the table starts like this.

      order_accessories
      PK_refno  PK_acc
      1         73
      1         74
      1         75
      1         86
      1         92
      

      Let’s also say that 75 is supposed to be 76. Assuming a sane user interface, the user can just change 75 to 76. A sane user interface would send this statement to the dbms.

      update order_accessories
      set PK_acc = 76
      where (PK_refno = 1 and PK_acc = 75);
      

      If 75 were not supposed to be there in the first place, then the user would just delete that one row. A sane user interface would send this statement to the dbms.

      delete from order_accessories
      where (PK_refno = 1 and PK_acc = 75);
      
      • 0
      • Reply
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
        • Share on LinkedIn
        • Share on WhatsApp
        • Report

    Sidebar

    Related Questions

    my SQL skills aren't strong enough to figure this out, hope someone can help.
    I have the following problem and hope someone could help. I have a SQL
    I have a strange issue with Hibernate 3.5 which I hope some one can
    I’m new to JQuery and I hope some experts can help me with a
    hope someone can help. I have two tables: Users -UserID -UserName UsersType -UserTypeID -UserID
    I hope someone out there can shed some light on the topic of creating
    I hope someone can help me with this, as I'm unable to find the
    I hope someone can help here, we're having an incredibly annoying time with Visual
    I need to do a non greedy match and hope someone can help me.
    I'm almost losing it, i really hope someone can help me out! I'm using

    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.