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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:09:52+00:00 2026-05-25T13:09:52+00:00

According to my previous Query that post i have a table that looks like

  • 0

According to my previous Query that post i have a table that looks like this:

|| *nid* || *language* ||
|| 8 || Chinese ||
|| 8 || Portuguese ||
|| 8 || German |

In which ‘nid’ and ‘language’ have a unique constraint.

With this setup how can i make sure that the there wont be any duplicate when i try to insert a new row ?

EDITED

I am guessing I should try to make a query such as:

SELECT * FROM lang WHERE nid = $nid AND language = $lang

If this return FALSE then i know i can now insert my data. Is this correct ?

  • 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-25T13:09:52+00:00Added an answer on May 25, 2026 at 1:09 pm

    Enforce the unique constraint by creating a unique key:

    ALTER TABLE the_table
    ADD UNIQUE INDEX nid_language_unique (nid, language);
    

    This constraint forbid two rows having the same nid and language.

    Any query attempting to violate the constraint will fail.

    As you want to ignore errors (and still abort the query), you can use INSERT IGNORE and UPDATE IGNORE:

    INSERT IGNORE INTO the_table (nid, language) VALUES (8, 'Chinese')
    /* row not inserted and no error */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table that I use to retrieve drive times, according to longitude
This question relates to one of my previous ones . I'd like to have
I have this previous post where I need to change my HTML form to
According to this discussion , the iphone agreement says that it doesn't allow loading
I have a SQL query that I'm currently solving by doing two queries. I
My SQL-Query should return a previous record(Claim). Previous means that it has a different
I've got this form working, but according to my previous question it might not
i am using this query select date_time_posting from table where FROM_UNIXTIME(date_time_posting,'%d-%m-%Y')='$c_day_date' where $c_day_date is
I have a table with this structure id integer parent_id integer order_n integer info
According to my small tests this code works. But, does it have undefined behaviour?

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.