News, views, tips and tricks on Oracle and other fun stuff

Query returning individual chars

Here is a query that puts each character of a given string in its own row:

select substr( 'eddie awad', rownum, 1) 
from all_objects 
where rownum <= length('eddie awad');

The table all_objects is used in the query as a row generator. Sweet.

Filed in Oracle, Tips on 19 Jul 05 | Tags: ,

Reader's Comments

  1. |

    Thanks, Eddie: that one is worth its weight in gold!

  2. |

    I like these simple yet powerful SQL statements. I’ll keep on posting such queries here as soon as I discover them.