既然是求交集,那么这两个表的关系模式应该是相同的了,
select
a.*
from
(select
*
from
table
order
by
table.a
desc
limit
10)
as
a,
(select
*
from
table
order
by
table.b
desc
limit
10)
as
b
where
a.primary_key
=
b.primary_key
--先将两个结果作为两张临时表,然后通过主键
primary_key来获取交集(交集肯定就是主键相等的了,因为关系模式相同)
mysql这垃圾不支持交集的。如果是数据库那么SQL如下SELECT id FROM a WHERE aid=5 INTERSECTSELECT id FROM a WHERE aid=6select * from mytable where pet in (select pet from mytable group by pet having count(pet)>1)获取同一pet数量大于1的pet并select出相关信息
select pet,count(pet) as per_count from mytable group by pet order by count(pet) desc limit 10
获取pet拥有量前十的pet和数量
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)