Tuesday, July 8, 2014

Contoh Query dengan fungsi Exists

Berikut ini beberapa contoh query dengan fungsi Exists SELECT * FROM USERID.BLOKIR_SALDO WHERE EXISTS ( SELECT 1 FROM USERID.SAVE_MASTER B WHERE B.KD_STATUS = '1' AND USERID.BLOKIR_SALDO.KD_CAB = B.KD_CAB AND USERID.BLOKIR_SALDO.NO_REK = B.NO_REK ) select t1.name, t1.id, 'Y' as HasChild from t1 where exists ( select 1 from t2 where t2.id = t1.id) UNION select t1.name, t1.id, 'N' as HasChild from t1 where NOT exists ( select 1 from t2 where t2.id = t1.id)