From: | Rajesh Kumar Mallah <mallah(at)trade-india(dot)com> |
---|---|
To: | Alex <alex(at)meerkatsoft(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Question on Select |
Date: | 2003-11-10 17:28:15 |
Message-ID: | 3FAFCAAF.20005@trade-india.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
select ref_code from tab_b where not exists (select * from tab_a where
item_id = tab_b.item_id);
make sure u have index on item_id in tab_a .
the above sql is quite efficient , other method is to use left join.
Alex wrote:
> Hi,
> I have two tables,
> Table A: item_id
> Table B: item_id, ref_code
> and i want to list all ref_codes in table B that are not referenced
> by Table A.
> Table A has about 3million records./ table B 200
>
> What is the best way to do that ?
>
> Thanks
> Alex
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
> message can get through to the mailing list cleanly
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2003-11-10 17:41:22 | Re: case-sensitive sorting and locale settings? |
Previous Message | Kathy Zhu | 2003-11-10 17:22:25 | Re: SQL-question: returning the id of an insert querry |