譬如select count(*) from A where type = 'dog'
select count(*) from A where type = 'cat'
这两个怎么合并呢?
这里我只是举个例子每个类型的结果我都是需要的,另外条件查询会更复杂的,可能还是 addtime > And addtime < **
学习是最好的投资!
直接用 UNION ALL 合并查询内容可否
UNION ALL
SELECT count(*), 'dog' as type FROM A WHERE type='dog' UNION ALL SELECT count(*), 'cat' as type FROM A WHERE type='cat' AND addtime > '2016-0-11-14'
type IN ('dog','cat')
select count(*) from A where (type = 'dog' or type = 'cat')
直接用
UNION ALL
合并查询内容可否type IN ('dog','cat')