Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2009
    Location
    Chelan, Washington, USA
    Posts
    2

    Question Unanswered: Smart Address search algorithm

    Hi Everyone,

    I found this post from two years a go:
    http://www.dbforums.com/mysql/163519...ml#post6365132

    I am looking to do the same exact thing, but I seem to be having issues figuring out the best approach.

    Does anyone have some suggestions?? Any help would be greatly appreciated.

    I am using PHP and MySQL.

    Thank you.

    -- Eric

  2. #2
    Join Date
    Jun 2007
    Location
    London
    Posts
    2,527
    Quote Originally Posted by erick_the_redd
    Does anyone have some suggestions??
    It seems simple enough. Just pull cities that match the search string and combine that with addresses that match the search string when there isn't a city match. A bit like this:
    Code:
    select city as matches
    from   Cities
    where  city = "%${SearchStr}%"
    union
    select concat( city, ' , ', address )
    from   Addresses
    where  not exists(
                select 1
                from   Cities
                where  city = "%${SearchStr}%" )
           and address like "%${SearchStr}%"
    limit 20

Posting Permissions

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