既然是求交集,那么这两个表的关系模式应该是相同的了,
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的语法是这样的,首先你得创建一张新的表C(创建表按照你的需要来创建,这里我按照(两个表中时间time相同(time是精确到秒的)的时候,把id这个字段的交集存到另一个新表中)你需要的来创建,就是只要一个id,用两个字段来保存)。然后代码为:insert into 表C select a.id as id1,b.id as id2 from 表A a,表B b where a.time = b.time这样就可以了。。
select create_date,count(*) as regeister from tablename where create_date between 'startdate' and 'enddate' group by create_date欢迎分享,转载请注明来源:内存溢出
评论列表(0条)