34,838
社区成员




SELECT a.* FROM ta a
INNER JOIN
(SELECT id FROM tb group by id) b
ON a.id=b.id
select id from a where exists(select 1 from b where a.id=b.id)
select id from A where id in (select id from B)
--> 變成下面怎麼不一樣了?
select id from A
inner join (select distinct id from B) t
on A.id=t.id
select id from A where id in (select xyrid from B)
-->
select id from A
inner join (select distinct xyrid from B) t
on A.id=t.id
SELECT a.* FROM ta a
INNER JOIN
(SELECT DISTINCT id FROM tb) b
ON a.id=b.id
--在id上建立索引
select a.id from a join b on a.id=b.id
--id上建立索引
select
*
from A
inner join B on A.id=B.id
create index index_name on a(id)
create index index_name on b(id)
select id from A
inner join (select distinct id from B) t
on A.id=t.id
--A,B表分别在id上建立索引
select id from A
join (select distinct id from B) t
on A.id=t.id