SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    United Kingdom
    Posts
    59
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How do I echo only results beginning with a certain letter?

    Hi there..

    My php script is performing this query:

    $query = "SELECT * FROM Race_Details WHERE Race_ID LIKE '%".$searchrace."%'";

    What I would like to do is then echo results back where the column Points_ID begins with a certain letter. I have five points groupings, those beginning with Q, R, C, E and T. So, how do I filter the query results using php to only echo back records where the Points_ID begins with Q for example?

    (Also, I would love to then also know how to sort these results by Points_ID - is it as simple as adding ORDER BY Points_ID to the query?)

    kemi

  2. #2
    SitePoint Wizard Young Twig's Avatar
    Join Date
    Dec 2003
    Location
    Albany, New York
    Posts
    1,355
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Beginning with Q and sorting by Points_ID ascending?
    PHP Code:
    $query "SELECT * FROM Race_Details WHERE Race_ID LIKE '%".$searchrace."%' AND Point_ID LIKE 'Q%' ORDER BY Points_ID ASC"


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
  •