select *,(select count(*) from test where num='142') where num='142';SELECT *: 显示所有记录 count(*): 聚合函数
这个是MYSQL中的一个非标准语句。即在 select ... group by 中,如果没有在 group by 中列出的字段,则MYSQL自行选择一个。 所有当 select *, count(*) 时,相当于group by 中什么都没列出。则所有字段由MYSQL自行选取出一条,一般是选取第一条。
count(*): 聚合函数
from test a,(select count(*) from test where num='142') b
where num='142';