【发布时间】:2014-12-01 12:07:59
【问题描述】:
我有一个表追随者和追随者..
想在一个存储过程中获取两者的计数。是否可以在同一张表上使用不同 where 条件的两个选择查询?
CREATE TABLE Table1
([val1] int, [val2] int, [val3] int, [val4] int, other int)
;
INSERT INTO Table1
([val1], [val2], [val3], [val4], other)
VALUES
(1, 26, 13, 1, 1),
(2, 13, 26, 1, 1),
(3, 10, 26, 1, 1),
(4, 26, 13, 1, 1),
(5, 14, 26, 1, 1)
;
我的选择查询
(select count(*) as following_count from table1 where val2=26)
(select count(*) as follower_count from table1 where val3=26)
【问题讨论】:
标签: mysql sql sql-server stored-procedures