Select against multi tables causing duplicates
Posted on 2005-05-05
Hi, I have a SELECT going against a couple tables, and I am getting duplicate records back.
Can someone help me re-write the SQL to get back distinct records?
Table1: cdrm_successor_borrower - Columns: sb_id, sb_name
Table2: cdrm_pool_sb - Columns: sb_id, pool_id, isDefault
SELECT DISTINCT sb.sb_name, psb.isDefault, sb.sb_id FROM cdrm_successor_borrower sb, cdrm_pool_sb psb WHERE sb.sb_id in (SELECT sb_id FROM cdrm_pool_sb WHERE pool_id = '1000') ORDER BY sb.sb_id
I am trying to get back all the records from the "bridge" table (cdrm_pool_sb) where the pool_id = 1000, in this case!