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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:29+00:00 2026-05-28T08:05:29+00:00

I have read many article about this one. I want to hear from you.

  • 0

I have read many article about this one. I want to hear from you.
My problem is:
A table: ID(INT, Unique, Auto Increase) , Title(varchar), Content(text), Keywords(varchar)

My PHP Code will always do insert new record, but not accept duplicated record base on Title or Keywords. So, the title or keyword can’t be Primary field. My PHP Code need to do check existing and insert like 10-20 records same time.

So, I check like this:

SELECT * FROM TABLE WHERE TITLE=XXX   

And if return nothing, then I do INSERT.
I read some other post. And some guy say:

INSERT IGNORE INTO Table values()

An other guy suggest:

SELECT COUNT(ID) FROM TABLE

IF it return 0, then do INSERT

I don’t know which one faster between those queries.

And I have 1 more question, what is different and faster on those queries too:

SELECT COUNT(ID) FROM ..
SELECT COUNT(0) FROM ...
SELECT COUNT(1) FROM ...
SELECT COUNT(*) FROM ...

All of them show me total of records in table, but I don’t know do mySQL think number 0 or 1 is my ID field? Even I do SELECT COUNT(1000) , I still get total records of my table, while my table only have 4 columns.

I’m using MySQL Workbench, have any option for test speed on this app?

  • 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-28T08:05:29+00:00Added an answer on May 28, 2026 at 8:05 am

    SELECT COUNT(*) FROM .... is faster than SELECT COUNT(ID) FROM .. or build something like this:

    INSERT INTO table (a,b,c) VALUES (1,2,3)
         ON DUPLICATE KEY UPDATE c=3;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read this great article by Mkyong about one-to-many relationship in Hibernate and
I use webforms.reportviewer. I have already read many blog and article about report pagination
I have read many answers to questions about dynamically resizing NSWindows and nothing has
I have read many answers regarding this still i am getting confused if i
I have read many question about improving the performance of C++ and C code
I have read many questions about Android, J2ME and RecordStore , but I still
I have read many questions about the facebook login but until not I didnt
I have been going through the web about this exception. I found many articles
I have just read an article about the Curiously Recurring Template Pattern. And you
I've recently read an article http://www.ravelrumba.com/blog/static-cookieless-domain/ about Serving Static Content from a Cookieless Domain

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.