views:

29

answers:

2

scenarioi:- 1) User enters an address into a search field. Address maybe zip,state or country

2) Now i have to take that address which may be in any order or which may just contain the country, state or zip and check the database if the the results exists or not.

Any advice on this topic would be awesome

+1  A: 

How about this one?

'SELECT * FROM table WHERE address LIKE \''. addslashes($search) .'\'
  OR zip = '. (int)$search .'
  OR country LIKE \''. addslashes($search) .'\''
JochenJung
i think this will be slow once the databae accumulates large volumes of data.was looking for something like a FULL TEXT SEARCH solution
soden
+1  A: 

I would do something like :

split address on space

build where clause as

WHERE zip||state||country like '%address_part_one%'
   OR zip||state||country like '%address_part_two%'
and so on ...

If you have fulltext enabled for the three fields :

WHERE MATCH (zip,state,country) AGAINST ('address_part_one')
   OR MATCH (zip,state,country) AGAINST ('address_part_two')
...
M42
can i do this type of search with full text support ?
soden
can full text search be enabled on views?
soden
I don't think it's possible to create an index on a view in MySQL. But may be i am wrong. Have a look at the doc.
M42