Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006

    Unanswered: a special select

    Hi, i have a table with a column "Album", defined as varchar.
    Suppose i have the following rows:

    id Album
    ++ +++++
    1 abc
    2 bbc
    3 cbc
    4 980
    5 890
    6 7AAD

    and i want to select all records with the album field starting with numbers, i.e., id=4,5,6. how can i do this please?

    thanks in advance!

  2. #2
    Join Date
    Nov 2003
    Provided Answers: 8
    SELECT id, album 
    FROM theTable
    WHERE substring(album,1) in ('1','2','3','4','5','6','7','8','9','0');
    You might want to create an index on substring(album,1) if your table is very large (otherwise PG will always do a sequential scan, which might be slow)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts