count(*)和count(column_name),mysql有什么区别。
count(*)
count(column_name)
COUNT(*)
COUNT(column_name)
column_name
COUNT(1)
要查看结果的差异,您可以尝试以下小实验:
CREATE TABLE table1 (x INT NULL); INSERT INTO table1 (x) VALUES (1), (2), (NULL); SELECT COUNT(*) AS a, COUNT(x) AS b, COUNT(1) AS c FROM table1;
结果:
abc 3 2 3