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 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
    • 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-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

    I hope someone can guide me as I'm stuck... I need to write an
    I hope someone could help me on this. I want to add a month
    This really, really urks me, so I hope that someone can give me a
    i'm trying to set up the selenium-maven-plugin and having some difficulties i hope somebody
    Hope anyone can shed light on this so I can use pens with dash
    Say I have 2 tables: Customers and Orders. A Customer can have many Orders.
    I have a CATEGORIES table that links to an ITEMS table (one to many).
    I have some inlines in one of my admin models which have default values
    comrades) I've found some interesting behavior of Invalidate method in multithreaded applications. I hope
    The docs at www.fastcgi.com aren't clear on this (to me), so I hope someone

    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.