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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:26:04+00:00 2026-06-15T00:26:04+00:00

OK the question is NOT about how to return the ID, but more like

  • 0

OK the question is NOT about how to return the ID, but more like how to skip it… I have a situation where i use last_insert_id() to get the id of the last inserted row, but i want to get a zero if no row is inserted. The problem is as follows:

  • i insert…update a few records: all IDs are returned since the rows are freshly inserted
  • then i repeat the process: this time IDs are not returned. YAY! that’s exactly what i want
  • i change one column value and repeat the process: but now the ID is returned for the row i’ve changed the column value in. And this is making me very angry. I don’t want mysql to return the ID at all if it’s not inserting anything

so to sum up:

  • when inserting new records: IDs are returned
  • when inserting identical records: IDs are not returned
  • when updating a value: updated IDs of the updated rows are returned 🙁

Is there a workaround for this?

I know this happens because mysql probably does not perform an update on identical records, but still … i’d sure like to know how to work around this.

  • 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-06-15T00:26:06+00:00Added an answer on June 15, 2026 at 12:26 am

    You should be able to retrieve the number of rows inserted and use that to determine if anything was inserted. If you’re using “raw” queries (i.e. no API that might otherwise provide the number of rows inserted), it looks like ROW_COUNT() might give you what you want.

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

Sidebar

Related Questions

My question is not about a specific code snippet but more general, so please
My question is not about how to solve this error(I already solved it) but
This question is not about 'best' barcode library recommendation, we use various products on
This is not a question about jQuery, but about how jQuery implements such a
I have a question about a particular query I'd like to execute against a
I've already checked this.. similar question but I am not convinced about the answers...
There are some discussions about the same question but I would like to ask
I'd like ask a question about building applications in .NET that use data from
This is more or less a general question and not about any specific ORM
This question is not about caching. I need this in-memory table for many small

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.