Home >Backend Development >PHP Tutorial >How does mysql query the value of id = category id in the same table?

How does mysql query the value of id = category id in the same table?

WBOY
WBOYOriginal
2016-08-04 09:21:541161browse

I want to check how many members each user recommended? What members are there?

As shown in the picture How does mysql query the value of id = category id in the same table?

Reply content:

I want to check how many members each user recommended? What members are there?

As shown in the picture How does mysql query the value of id = category id in the same table?

<code>select id,user_name,(select count(1) from user where recommend_id=u.id )recommend_count  from user u</code>

Use aliases to turn this table into two tables and just associate them

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