这条子查询如何改为联合查询? select * from tbl where rid = 6 and id in (select id from tbl where rid = 7) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select * from tbl where rid = 6 and id in (select id from tbl where rid = 7)楼主你是不是弄错了?这条语句不就等于select * from tal where rid=6 and rid=7吗? select id from tbl as t1 inner join tbl as t2 using(id) where t1.rid = 7 and t2.rid = 6; 这两者并不等价,我原sql的意思是要取出rid为6和rid为7的交集!但条件rid=6 and rid=7的结果则为空集!一个字段的值是唯一的,即等于6又等于7,怎么可能? select distinct a.*from tbl a , tbl bwhere a.rid=6and b.rid=7and a.id=b.id select a.*from tb1 a join tb2 b on a.id=b.idwhere a.rid=6 and b.rid=7; select a1.* from (select * from tbl where rid = 6) a1 , (select id from tbl where rid = 7) a2where a1.id = a2.id mysql服务启动问题 看看这个题目,能不能改进一下啊。 在mysql数据库中 怎样存取ip比较合理 limit不同查询时间的差异 mysql数据库中表数据带回车,怎么去掉,急等解决! 一个大表130万条 ,现在还在增加索引 请问Mysql 5.1.30 community 支持事件调度器吗? MySQL-Front的问题 MYsql的安装问题 near '1,'??‰?????”??‰','35',1,35)' at line 1有人知道怎么回事吗 memory table mysql 排它锁 实现
select id from tbl as t1 inner join tbl as t2 using(id) where t1.rid = 7 and t2.rid = 6;
这两者并不等价,我原sql的意思是要取出rid为6和rid为7的交集!但条件rid=6 and rid=7的结果则为空集!一个字段的值是唯一的,即等于6又等于7,怎么可能?
from tbl a , tbl b
where a.rid=6
and b.rid=7
and a.id=b.id
from tb1 a join tb2 b on a.id=b.id
where a.rid=6 and b.rid=7;
select a1.*
from (select * from tbl where rid = 6) a1 , (select id from tbl where rid = 7) a2
where a1.id = a2.id