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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:22:16+00:00 2026-05-15T11:22:16+00:00

This is what I’m doing right now ( name is UNIQUE ): SELECT *

  • 0

This is what I’m doing right now (name is UNIQUE):

SELECT * FROM fruits WHERE name='apple';

Check if the query returned any
result. If yes, don’t do anything. If
no, a new value has to be inserted:

INSERT INTO fruits (name) VALUES ('apple');

Instead of the above is it ok to insert the value into the table without checking if it already exists? If the name already exists in the table, an error will be thrown and if it doesn’t, a new record will be inserted.

Right now I am having to insert 500 records in a for loop, which results in 1000 queries. Will it be ok to skip the “already-exists” check?

  • 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-15T11:22:17+00:00Added an answer on May 15, 2026 at 11:22 am

    You can use the IGNORE feature:

    INSERT IGNORE INTO fruits VALUES ('apple')
    

    If there is a key violation, it just skips this value

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

Sidebar

Ask A Question

Stats

  • Questions 511k
  • Answers 511k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The W3C's HTML validator is open source so you can… May 16, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer I think you don't want to use the new selector,… May 16, 2026 at 5:09 pm
  • Editorial Team
    Editorial Team added an answer OK, here's what I got: D3DTSS enumeration (containing default values… May 16, 2026 at 5:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

this is what i have right now Drawing an RSS feed into the php,
Does anyone know how can I replace this 2 symbol below from the string
For some reason, after submitting a string like this Jack’s Spindle from a text
this is dankogai's javascript deflate http://github.com/dankogai/js-deflate I can't inflate from c#,please help me
This is some sample text from a large text file. (2, 1, 3, 2,
I am currently running into a problem where an element is coming back from
I'm looking for suggestions for debugging... If you view this site in Firefox or
This is my first time using the synchronized keyword, so I am still unsure
This code is works fine when you type 22 and 56 for example, it
This is a sort of trivial question but something I've been wondering about. In

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.