SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Rusted & Weathered HumanClay's Avatar
    Join Date
    Sep 2000
    Location
    Milwaukee, WI
    Posts
    225
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Searching a database

    I have certain names stored in a table, and I want to be able to search the database by letters/numbers. For example, I can list all values that start with A:

    SELECT * FROM table WHERE name LIKE 'A%';

    How would I go about listing any names that begin with the numbers 0-9? Is there a way to do this with one SELECT statement, or do I need to use a loop? If you need a loop, how would that look? I'm not quite sure how to do that.
    Steve Caponetto - [profile] [e-mail]
    CreedFeed.com - feed your need for Creed!

  2. #2
    SitePoint Enthusiast
    Join Date
    May 2001
    Location
    lalal
    Posts
    85
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select * from table where column regexp '^[0-9]';

    http://www.mysql.com/documentation/m...al_Regexp.html


Bookmarks

Posting Permissions

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