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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:44:07+00:00 2026-06-09T15:44:07+00:00

I have below SQL statment INSERT INTO my_counts (type,code,count) SELECT type,id ,1 from my_data

  • 0

I have below SQL statment

INSERT INTO my_counts (type,code,count) SELECT type,id ,1 from my_data WHERE user_id=10
ON DUPLICATE KEY UPDATE count = count + 1; 

Here type,code is a composite primary key .

Could you please let me know how can I find out the number of records inserted and also the number of records updated separately ?

I know SELECT ROW_COUNT() gives the effected rows ( 2 for update and 1 for insert) .
But how to find out separately

1) the number of rows updated 
2) the number of rows inserted

Thanks for your help

Regards

Kiran

  • 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-09T15:44:08+00:00Added an answer on June 9, 2026 at 3:44 pm

    I don’t know of a good way to get this from the diagnostics information.

    In any case, supposing that you’ve controlled it so that only the rows just INSERT ed are in the table (or will only be queried), this can be simply retrieved after the fact:

    SELECT COUNT(*) as Inserted, SUM(count - 1) as Updated
    FROM my_counts;
    

    (please note that, as included in my SQLFiddle example, these numbers can actually be predicted from the base data).

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

Sidebar

Related Questions

I have the code below: string SQL = select * from + TableName; using
I have this SQL statement below INSERT into 2011_electricity ( date, energy, daynum) VALUES
Kindly do have a look at below mentioned SQL: $sql =INSERT INTO demo_participant (name,
I have an SQL query (below) that essentially takes a student from tbStudents, and
I use the code below to insert data into my sqlite-database but for some
I have the following SQL design issue. The code below might look a little
In SQL server 2008, I have select statement that spits below text output. 'text1d','text2','text3'
I have the below code that splits the sql statement and give its indices
I have a problem with the SQL statement detailed below. The query returns the
i have four tables like below in sql server 2008 : TABLE 1 ->

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.