How to Select all rows starting with numbers and spl chars

  • Hi

    I have a table with one column

    Shop Name

    ---------------

    123 Shop

    #56 Shop

    @shop-2

    Astar Shop

    Best Shop

    I want to write a sql select statement and produces the following result

    Shop Name

    ---------------

    123 Shop

    #56 Shop

    @shop-2

    Please help me on this

    Cheers

    -Jag

  • Use the LIKE keyword:

    select [Shop Name] from mytable where [Shop Name] like '[0-9]%'

    for numbers, or

    select [Shop Name] from mytable where [Shop Name] like '[^a-zA-Z]%'

    for ones that do not start with a letter

    Regards,

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

  • Thanks Andras

    But this doesn't select rows starting with special characters like #,%,* etc.

    How do I write a single query to select all rows starting with numbers and spl characters

  • sorry andras

    my mistake. I didnt notice the second query though

    Cheers

    -Jag

  • poztme (2/1/2008)


    sorry andras

    my mistake. I didnt notice the second query though

    Cheers

    -Jag

    Not your fault, I've added it later (the title of your post was truncated so I did not see the "and spl chars"). Hope this works for you.

    Andras


    Andras Belokosztolszki, MCPD, PhD
    GoldenGate Software

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply