gpt4 book ai didi

mysql - 选择并计算行数

转载 作者:行者123 更新时间:2023-11-29 11:28:42 24 4
gpt4 key购买 nike

我有 2 个表,我需要在一个查询中选择并计算行数,也许有人可以帮助我,我的查询是:

SELECT
c.id, c.first_name, c.last_name, c.speciality, c.level, c.email, c.skype, c.city,
s.status_type, c.status_id, c.linkedin, c.link_cv, c.interview_res, c.createdAt,
c.updatedAt, c.recruiter_id, u.first_name AS fname, u.last_name AS lname
FROM
Candidates c
JOIN Users u
ON c.recruiter_id = u.id
JOIN Statuses s
ON s.id = c.status_id
WHERE
c.deleted = false

我需要获取响应我的选择的行数并对其进行计数。

示例输出(我想要的):

count | fname  | lname  | ..... |
---------------------------------
3 | Ihor | Shmidt | ... |
3 | Andre | Agassi | .... |
3 | Roger | Federer| ..... |

即我想要我选择的字段及其计数

最佳答案

在查询的“来自”部分之前,请添加计数 (*)。它会给你行数。

Select ......, count (*) from Candidates c 
JOIN Users u ON c.recruiter_id = u.id
JOIN Statuses s on s.id = c.status_id
WHERE c.deleted = false;

关于mysql - 选择并计算行数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37777184/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com