Dalam hal pembersihan kode murni, berikut ini terlihat lebih bersih:
SELECT *
FROM foobar
WHERE (SUBJECT = 'STAT' and TERM IN ('111','222','666') )
OR (SUBJECT = 'COMM' and TERM IN ('333','444') )
OR (SUBJECT = 'ENGLISH' and TERM = '555' ) ;
Bergantung pada aplikasi dan seberapa sering logika akan digunakan kembali, mungkin perlu juga menyiapkan tabel pencarian untuk menerapkan logika:
CREATE TABLE foobar_lookup (SUBJECT VARCHAR2(7), TERM VARCHAR2(3)) ;
INSERT INTO foobar_lookup SELECT 'STAT', '111' FROM dual ;
INSERT INTO foobar_lookup SELECT 'STAT', '222' FROM dual ;
INSERT INTO foobar_lookup SELECT 'STAT', '666' FROM dual ;
INSERT INTO foobar_lookup SELECT 'COMM', '444' FROM dual ;
INSERT INTO foobar_lookup SELECT 'COMM', '333' FROM dual ;
INSERT INTO foobar_lookup SELECT 'ENGLISH', '555' FROM dual ;
SELECT f.* FROM foobar f
JOIN foobar_lookup fl
ON fl.subject = f.subject
AND fl.term = f.term ;