473,385 Members | 1,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

difference in number of records for select count(*) and select *

We are trying to do select count(*) and select * from the same table.

We have executed the following:
when we execute
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*)
  2. FROM TABLE1;
  3. the result is 0
  4.  
but when we execute
Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM TABLE1;
the result is..
Expand|Select|Wrap|Line Numbers
  1. COLUMN1   COLUMN2
  2. 1                 A
  3. 2                 B
two records selected.

what could possibly cause this discrepancy?
Dec 30 '07 #1
3 2566
MindBender77
234 100+
Hello,

Select (*) - will count the total number of records in the table

Select * - will list all records in the table
Jan 3 '08 #2
docdiesel
297 Expert 100+
Hi,
Select (*) - will count the total number of records in the table
Select * - will list all records in the table
Yes, correct. But the "SELECT count(*) should have given 2 as result, not 0 (zero), for there're two rows in the table. Try a
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   count(column1)
  3. FROM
  4.   table1
or another column. What's the result?

Regards,

Bernd
Jan 4 '08 #3
We have REORG the table. This seems to solve the problem. The number of records for select * and select count(*) are now the same.

But I still want to know the reason behind it.

I'll try the select count per column if the problem arises again.

I'll give an update regarding this..Super thanks!

=================================================



Hi,

Yes, correct. But the "SELECT count(*) should have given 2 as result, not 0 (zero), for there're two rows in the table. Try a
Expand|Select|Wrap|Line Numbers
  1. SELECT
  2.   count(column1)
  3. FROM
  4.   table1
or another column. What's the result?

Regards,

Bernd
Jan 16 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Bryan Zash | last post by:
When querying a bit field, I am encountering a problem with MS SQL Server returning a larger number of records for a table than the actual number of records that exist within that table. For...
3
by: Anne | last post by:
Hi I have got a table with some sales transactions. It has got 3 fields 1) Ordernumber 2) Item number 3) Shippingdate Now I want to make ONE (not two) query that shows how many different...
5
by: JIM.H. | last post by:
Hello, What is the easiest way to run a select SQL string and find out the number of row returned. If you give a code example it would be helpful? Jim.
5
by: Quentin Huo | last post by:
Hi: I want to retrieve a set of records from the query like: "SELECT * FROM tVisitors WHERE vTime>'1/1/2004'" And then I will put a part of records into a DataSet by: DataSet ds = new...
2
by: msch-prv | last post by:
Hi, I have a paged gridview (Apts_grd) tied to an Access DataSource (Apts_srcGrd). How do I get the total number of data records returned by the query? The following shows only the number of...
9
by: HC | last post by:
Hello, all, I started out thinking my problems were elsewhere but as I have worked through this I have isolated my problem, currently, as a difference between MSDE and SQL Express 2005 (I'll just...
3
by: Otto | last post by:
Hi I'm migrating from Access til MySQL. Works fine so far - but one thing is nearly killing me: I got the count of total records in a variabel - (antalRecords) I got the count for the Field Q1...
2
by: weird0 | last post by:
What is the best way to count the number of records in a MS SQL DB. The way I do it is executeReader() and loop through all the records in a db and increment variable RowCount++. Is there...
0
by: KrazyKoder | last post by:
Hello, I have MS Access form that basically allows the user to configure an update statement to a single table via the gui. A requirement is to show the count of records that will be updated...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.