Wednesday, July 2, 2008

Using LIKE in SQL

SELECT D.NOSTAF_DRIVER,
D.NODETAIL,
D.TKH_PERGI,
D.TKH_PULANG,
V.VREGNUM,
T.LOC_CODE,
T.LOC_DESC
FROM DETAIL D,
VEHICLE V,
TEMPAHAN T
WHERE ( D.VHCLCODE = V.VCODE ) and
( D.IDTEMPAH = T.IDTEMPAH ) and
( ( D.NOSTAF_DRIVER LIKE '%' ) AND
( TO_CHAR(D.TKH_PERGI, 'YYYY') = '2008' ) AND
( TO_CHAR(D.TKH_PERGI, 'MM') like '01' ) )
ORDER BY D.TKH_PERGI ASC

This SQL will retrieve all data for DETAIL table where NOSTAF_DRIVER equal '%' (all data)

No comments: