1、select 1 from table 与 select anycol(table中的任意一行) from table 与 select * from table 作用上没有差别,都是查询是否有记录。select 1 from table 中的“1”是一个常量,所以查询出来的所以行都是它,但从效率上来说:1 > anycol >*,因为不用查字典表。
2、查看记录条数可以用select sum(1) from table; 等价于 select sum(*) from table;
3、(1)select 1 from table 增加临时列,每行的列值是写在select后的数,这条sql语句中是1
(2)select count(1) from table 不管count(a)的a值如何变化,得出的值总是table表的行数
(3)select sum(1) from table 计算临时列的和。