www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Get a specific list of postcodes with MySQL Like Operator

  1. #1
    Join Date
    Jun 2007
    Posts
    25

    resolved [RESOLVED] Get a specific list of postcodes with MySQL Like Operator

    Hi everyone.

    I have list of postcodes. And what i'm trying to do is get a listing of similar poscodes only.

    My Code:
    PHP Code:
    $postcode1 ereg_replace('[^A-Za-z]'''$postcode);

    SELECT FROM coverparked WHERE postcode LIKE '$postcode1%' ORDER BY postcode 
    So then $postcode1 strips all number from postcode, so for example E16 is strpped down to E only, then using the mysql query i get all the postcodes from database starting with E, problem is that i also get listing of postodes starting with EC, EN ... and i want postcodes sarting with E only.

    Tried some options but i can't get to make it work..

    Can you help me out here please ..

    Thanks a lot in advance in advance.

  2. #2
    Join Date
    Mar 2009
    Posts
    452
    hope the following works for you

    mysql_query("SELECT * FROM coverparked WHERE postcode regexp '^{$postcode1}[0-9]{1,}' ORDER BY postcode");

    also read here http://dev.mysql.com/doc/refman/5.0/...-matching.html
    Last edited by ZABI; 05-03-2013 at 09:05 AM.

  3. #3
    Join Date
    Jun 2007
    Posts
    25
    Thanks a lot ZABI - works perfect ...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles