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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T02:15:53+00:00 2026-06-01T02:15:53+00:00

i have a sql query where i count the number of rows SELECT count(*)

  • 0

i have a sql query where i count the number of rows

SELECT count(*) AS `nr` FROM `ordine` WHERE (ditta_id = '3') AND (YEAR(`data`) = '2012') AND (stato = 'approvato' or stato = 'consegnato') LIMIT 1

I update some row changing stato into ‘approvato’, sometimes count() gives me the right number, sometimes it gives me the old number

Here is a piece of my logs:

2012-03-23T10:42:45+01:00 DEBUG (7): Row id = 1809
2012-03-23T10:42:45+01:00 DEBUG (7): SELECT count(*) AS `nr` FROM `ordine` WHERE (ditta_id = '3') AND (YEAR(`data`) = '2012') AND (stato = 'approvato' or stato = 'consegnato') LIMIT 1
2012-03-23T10:42:45+01:00 DEBUG (7): Result = 140
...change stato into 'approvato' thus count must give me 141 next time, requery the row, check changes are saved


2012-03-23T10:44:52+01:00 DEBUG (7): Row id = 1810
2012-03-23T10:44:52+01:00 DEBUG (7): SELECT count(*) AS `nr` FROM `ordine` WHERE (ditta_id = '3') AND (YEAR(`data`) = '2012') AND (stato = 'approvato' or stato = 'consegnato') LIMIT 1
2012-03-23T10:44:52+01:00 DEBUG (7): Result = 140 ?!!! why not 141?

ditta_id, agente_id, stato are indexes

I am using Zend Framework 1.11.11 and MySQL 5.1.49-3

  • 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-01T02:15:54+00:00Added an answer on June 1, 2026 at 2:15 am

    For the row you updated, I assume one of the following to be true…

    • ditta_id is not '3'
    • YEAR(data) is not '2012'
    • stato was already 'approvato'
    • stato was already 'consegnato'
    • The new value in stato has a typo

    Are you able to show us these fields before and after you change the stato field?

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

Sidebar

Related Questions

I have the following SQL query: select expr1, operator, expr2, count(*) as c from
I have an SQL Server query that needs to count the number of rows
I have a simple SQL query: Select ID, COUNT(ID) as Selections, OptionName, SUM(Units) as
i have sql query select * from Roles Join Users On Roles.Role=Users.RoleId it return
I have this SQL query: SELECT * FROM IMAGES WHERE IMAGENAME in ('IMG1', 'IMG2',
I have a SQL Server database. I want to count number of rows where
I have a SQL Server 2008 query SELECT TOP 10 * FROM T WHERE
I have defined the following query: select count((select * from producers)) from producers; Assuming
I have array number = {2,3,4,5,6} Now i have to select rows from table
I have an sql query that counts the number of results for a complex

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.