Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    Sinapore
    Posts
    187

    Unanswered: question on using LIKE...

    Hi,

    I've a similar question to the one I asked at http://www.dbforums.com/t982096.html. Given the following columns and their corresponding entries, how do I select only words beginning with a certain letter?

    Code:
    column1    column2    column3
    cheer        town          greed
    occupy      serene       addicted
    provide     astute        recoup
    able          cool           health
    bright        tanned       abort
    I was playing with something like the following to select words beginning with the letter 'A' without much luck:
    Code:
    SELECT column1, column2, column3
    FROM words
    WHERE ??? LIKE 'A%'
    I don't know what to put in place of ???.

    Hope someone can enlighten me

    TIA

  2. #2
    Join Date
    Jan 2004
    Location
    Aberdeen
    Posts
    12
    select column1, column2, column3
    from words
    where column1 like 'A%'
    or column2 like 'A%'
    or column3 like 'A%'

    However, you'd get the following back

    occupy serene addicted
    etc.

    If you only want addicted, astute, able and abort back then
    I'd suggest three queries.

    select column1
    from words
    where column1 like 'A%'

    select column2
    from words
    where column2 like 'A%'

    etc.

  3. #3
    Join Date
    Nov 2003
    Posts
    91
    select column1 from yourtable where column1 like 'A%'
    union
    select column2 from yourtable where column2 like 'A%'
    union
    select column3 from yourtable where column3 like 'A%'
    order by 1;

  4. #4
    Join Date
    Nov 2003
    Location
    Sinapore
    Posts
    187
    Originally posted by vanekl
    select column1 from yourtable where column1 like 'A%'
    union
    select column2 from yourtable where column2 like 'A%'
    union
    select column3 from yourtable where column3 like 'A%'
    order by 1;
    Thanks, vanekl! I'm ashamed I didn't think of trying that...


Posting Permissions

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