List mysql results by#, or Letter starts with?

Discussion in 'PHP' started by puffyz, Jul 9, 2008.

  1. #1
    Hey everyone, anyone know how, have a script handy or know of one out there that can list mysql results by # or Letter they start with?...IE:

    #
    List all mysql results in table that start with a #

    A
    List all mysql results in table that start with a A

    B
    List all mysql results in table that start with a B

    .....

    Z
    List all mysql results in table that start with a Z

    thanks in advance!
    B
     
    puffyz, Jul 9, 2008 IP
  2. kmap

    kmap Well-Known Member

    Messages:
    2,215
    Likes Received:
    29
    Best Answers:
    2
    Trophy Points:
    135
    #2
    yes i have pm me to buy it

    Regards

    Alex
     
    kmap, Jul 9, 2008 IP
  3. Danltn

    Danltn Well-Known Member

    Messages:
    679
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    120
    #3
    LIKE...

    a%
    b%
    etc, you get the idea.
     
    Danltn, Jul 9, 2008 IP
  4. Mozzart

    Mozzart Peon

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Well... lets see if I grasped his post..

    You want to get the posts from number a to numbers what?

    If so then regex might just do the job for you
    
    SELECT * FROM whatever WHERE column REGEXP '^[aA]' 
    Code (markup):
    That will list from a to A only, check for more regex metacharacters and other things to complete your queries :) shouldn't be too hard to figure out at this level

    At the start of the line it will only output

    america
    Asia
    alvin

    you get the idea, it's a range.

    Another example:

    SELECT * FROM `configuration` WHERE `configuration_title` REGEXP '^[sSEe]' (from a zencart database i use, if you have one, try it)

    It will query from s to S and e to E at the start of each line
     
    Mozzart, Jul 9, 2008 IP