26 January 2006

SQL statement of the month of JAN/2006

How to find a field with space in between? Use the following SQL statement:

Find nama negeri with Gap or space.


1 select decode(translate(nama_negeri,' ',nama_negeri),
2 nama_negeri, 'not found', 'found') found_or_not, nama_negeri
3 from neg
4 where decode(translate(nama_negeri,' ',nama_negeri),
5* nama_negeri, 'not found', 'found') = 'found'
SQL> /

FOUND_OR_ NAMA_NEGERI
--------- --------------------
found WP KUALA LUMPUR
found Luar Negara
found WP LABUAN

No comments: