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

    Unanswered: select field starting with char

    Ok because this forums search sucks (google should stay on i can't find anything with the search. I'm sure this is extremely easy.

    What i'm trying to do is select all data (rows) that starts with a particular character.

    For example i have the following table

    id | data
    1 | abc
    2 | bcd
    3 | zkb
    4 | aht

    now i need to pull all the fields containing the letter a (or A) as the first letter of the first word. I know how to do this in php but can't find anything for mysql. I believe i could user a wildcard char (%) in there but would that be the best way? it seems like that would put additional load on the server that isn't needed.

    Any help would be great

  2. #2
    Join Date
    Apr 2002
    Toronto, Canada
    select ...
      from ...
     where left(data,1) = 'a' | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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