Possible Duplicate:
In SQL, what's the difference between count(column) and count(*)?
As per subject, is there any difference in how MySQL interprets the above query? Or they are regarded as the same?
Possible Duplicate:
In SQL, what's the difference between count(column) and count(*)?
As per subject, is there any difference in how MySQL interprets the above query? Or they are regarded as the same?
The difference between the functions COUNT(*)
and COUNT(fieldname)
is that the second does not calculate NULL-values.
SELECT *...
returns all the fields in the selected tables. SELECT fieldname
returns only the specified field name.
It is more efficient using the second option, specially in cases where the table has many fields and some of them are not indexed. Selecting from those will take longer, and if you don't need there is no point in selecting all.
select(*) means you wants to select all fields available in the table. While select(fieldname) means you only want to select certain columns in the table.
For example, you have a table 'Users' with columns 'username', 'email', 'password'; you can do the following:
select (*) from Users
which will give you all 3 columns (username, email, password); or you can do:
select username, email from Users
which will only give you 2 columns (username, email).