I
I
iOS Dav2016-08-09 22:00:51
SQL
iOS Dav, 2016-08-09 22:00:51

So sql, ...count(*)... and ...count(id)... what is the difference?

In some sql queries they write ...count(*)... and in some ...count(id)... so what's the difference?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Nemiro, 2016-08-09
@Aidosss

SELECT COUNT(*) FROM - iterate over all rows.
SELECT COUNT(id) FROM - iterate over all rows in which the specified field (in this case id ) has a value other than NULL .
What to use is a matter of performance and needs. In the case of primary key , it's more of a performance issue, which will depend on the specific DBMS.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question