query for numeric/symbol first character

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • galilee99
    New Member
    • Sep 2008
    • 7

    query for numeric/symbol first character

    Hi, I have a query which gives me all names in the database based on first letter:

    Code:
    SELECT drinkid, drinkname FROM tDrinks WHERE drinkname like 'A%' ORDER BY drinkname
    How do I query for names starting with a symbol or a number. ie: if I had names in the database like '123 Martini' or '@the beach' how would I return those in a query.

    Thanks
  • xNephilimx
    Recognized Expert New Member
    • Jun 2007
    • 213

    #2
    you can use regexp to test if it doesn't start with a number or a letter:

    Code:
    SELECT drinkid, drinkname FROM tDrinks WHERE drinkname REGEXP '^[\D\W]' ORDER BY drinkname

    Comment

    Working...