这是我的查询,我仍然有点挂起mysql连接。我想得到这个查询的计数....
SELECT *
FROM `users`
WHERE id = '4'
UNION
SELECT *
FROM `users`
WHERE id IN
(SELECT group_id
FROM `users`
WHERE id = '4')
AND status = '1'
答案 0 :(得分:0)
您可以计算子查询
select count(*) from (
SELECT *
FROM `users`
WHERE id = '4'
UNION
SELECT *
FROM `users`
WHERE id IN
(SELECT level
FROM `users`
WHERE id = '4')
AND status = '1') t
答案 1 :(得分:0)
我同意scaisEdge要使用的代码。但是,您在子查询中尝试做什么?这似乎是寻找ID,但您选择了' Level'对于IN声明?除非LEVEL与ID相同,否则它不会做任何事情。
SELECT *
FROM `users`
WHERE id IN
(SELECT level
FROM `users`
WHERE id = '4')
AND status = '1'