views:

60

answers:

2

Is there a way using MySQL, to query a value containing a space, but as some sort of escape character? It's for an instant search engine I'm building (I'm trying to incorporate special search strings such as quotes to search for exact string).

cheers

A: 

select * from sometable where somefield like '%oh no%';

m1tk4
A: 

Full-text indexes are what you should use. They handle all sorts of key words/characters (such as quoting a string to get exact match, -someword for saying someword can't be in the result and +someword for saying someword has to be in the result) without having to do anything special in your code (other than changing your query a little). The database will do the search for you and return the most relevant results at the top of the query. It is really quite easy to get going too.

Mysql Manual

Using full-text searching (implementation help)

Jonathan Kuhn
thanks very much that's exactly what i needed :) cheers
Fela