Home  >  Article  >  Backend Development  >  关于select count(*) 的有关问题

关于select count(*) 的有关问题

WBOY
WBOYOriginal
2016-06-13 13:29:26851browse

关于select count(*) 的问题!
比如表结构和数据如下:

id typeid name

1 2 a

2 2 b 

3 3 c

4 3 d


我想实现 select count(*) as nums 。。。 where typeid=2 以及每一条记录的name,即所有的记录都出现,如下形式:

nums name
2 a
2 b


请问如何写 sql ? mysql5.0 以上版本

------解决方案--------------------
还可以这样喔。。


SELECT (select count(*) as nums from test.aa where bbb=2) , name FROM test.aa
可以倒我的系统执行一下 =_=..

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn