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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:25:44+00:00 2026-05-20T01:25:44+00:00

I’m storing a simple tag relationship and I’m wondering what would be the better

  • 0

I’m storing a simple tag relationship and I’m wondering what would be the better way to delete tags?

The two ways I know of:

  1. SELECT tag FROM content_tags WHERE
    content_id = 10
  2. Use php to compare the result with
    the new tags supplied and if there
    are any tags from the database
    result that are not in the new tags,
    run a delete query on that tag
  3. The rest of the tags are either new
    or already exist so I use INSERT
    INTO content_tags … ON DUPLICATE
    KEY UPDATE

Or simply:

  1. DELETE FROM content_tags FROM tags
    WHERE content_id = 10
  2. Insert each tag (no need to use ON
    DUPLICATE KEY UPDATE here as the
    tags for this content_id are
    already deleted at this point)

I’m current doing the first method, but the 2nd way seems to be much less of a hassle. But I’m not sure if it’s “bad” or inefficient to use delete in this fashion. Or if you have a better method feel free to share.

  • 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-20T01:25:44+00:00Added an answer on May 20, 2026 at 1:25 am

    You could adjust the first method to do also not do the inserts on tags that already exist. But it could (and probably will) still result in more queries then the second method, especially if you combine those insert statements in a single query.

    //small example 🙂

    INSERT INTO content_tags
    (content_id, tag_id)
    VALUES
    (1,1),
    (1,2),
    (1,3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've tracked down a weird MySQL problem to the two different ways I was
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
Seemingly simple, but I cannot find anything relevant on the web. What is the
I want use html5's new tag to play a wav file (currently only supported
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I would like to run a str_replace or preg_replace which looks for certain words

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.