Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-06-2012, 12:26 AM   PM User | #1
quadrant6
Regular Coder

 
quadrant6's Avatar
 
Join Date: Aug 2002
Location: New Zealand
Posts: 151
Thanks: 0
Thanked 0 Times in 0 Posts
quadrant6 is an unknown quantity at this point
Most efficient way of searching this

I have a table of Australian postcodes and address. There are 15k rows with each row looking like this:

Code:
postcode	|	suburb	|	state

2048  	|	Westgate	|	NSW
2066		|	Blah		| 	NSW

Triggered by a text input field with jQuery autocomplete, I'm running a search on the suburb and postcode using this code

Code:
SELECT address_id as id, CONCAT(suburb,' ',state,' ',postcode) as value FROM address WHERE address_id != ''"; 

foreach ($keywords as $keyword)
{
$query .= " AND (postcode like '".$keyword."%' OR suburb like '%".$keyword."%')";
}

Is that the most efficient way to do it? or should I be considering full text searching?

The above does basically work, I'm just not sure if it's the best practice.
quadrant6 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:59 AM.


Advertisement
Log in to turn off these ads.