sql command: cari customer2 id di table A yg gak ada di table B

coba pake, mudah2an membantu:

select xcus.* from table_A xcus where xcus.customer_id in (
select a.customer_id from table_A a
minus
select b.customer_id from table_B b
);

saran untuk performance issue kalo dijalankan di production database
krn ada jutaan record sebaiknya table_A dan table_B dibuatkan
 index untuk column customer_id

salam
semoga membantu
Christian Wiyoto



--- On Thu, 9/2/10, Rudy W Sitanggang <[email protected]> wrote:

> From: Rudy W Sitanggang <[email protected]>
> Subject: Re: [indo-oracle] Tanya selisih record antara dua tabel
> To: [email protected]
> Date: Thursday, September 2, 2010, 9:09 PM
> coba kalo begini.
> 
> select customer_id from table_A a
> where not exists (select 1 from table_B where
> customer_id=a.customer_id)
> 
> 
> 
> 
> 
> 2010/9/2 Yudho Adi Riyawan <[email protected]>
> 
> >
> >
> > Dear master,
> >
> > Misal saya punya dua tabel A dengan jumlah record
> 1.000.000 dan tabel B
> > dengan jumlah 800.000 record, masing masing masing
> mempunyai kolom
> > customer_id. Yang mau saya tanyakan bagaimana query
> yang paling efisien
> > untuk mencari customer_id dari tabel A yang tidak ada
> di tabel B ? Saya
> > biasanya pakai MINUS atau NOT IN.
> >
> > Salam
> >
> >  
> >
> 
> 
> 
> -- 
> Warm regards,
> 
> 
> Rudy Wardhany
> 
> 
> Yahoo ID: [email protected]
> 
> 
> [Non-text portions of this message have been removed]
> 
> 
> 
> ------------------------------------
> 
> --
> -----------I.N.D.O - O.R.A.C.L.E---------------
> Keluar: [email protected]
> Website: http://indooracle.wordpress.com
> http://www.facebook.com/group.php?gid=51973053515
> -----------------------------------------------
> 
> Bergabung dengan Indonesia Thin Client User Groups, 
> Terminal Server, Citrix, New Moon Caneveral, di:
> http://indo-thin.blogspot.comYahoo! Groups Links
> 
> 
>     [email protected]
> 
> 
> 


      

Kirim email ke