连表查询和子查询

连表查询:SELECT COUNT(D.ID) FROM UPG_BONDPOOL_DETAIL D,UPG_BONDPOOL_RECORD R WHERE D.RECORD_ID = R.ID AND R.PRODUCT_NO = 'B018';


子查询:select count(d.id) from upg_bondpool_detail d WHERE d.record_id in(select id from UPG_BONDPOOL_RECORD R where R.PRODUCT_NO = 'B018');


效果一样,连表查询的效率更高 

你可能感兴趣的:(连表查询和子查询)