mysql - SQL Text Search - EXACT before space, LIKE after in search term -


i'm trying create sql query supply values auto completion text field. working can't seem create sql query exact enough purposes want. using mysql.

if there space (or multiple spaces) in search term, want query comparison on part of string after last space.

for example, have 2 possible values in database:

  • bolt
  • bolts large

currently if user types 'bolt' space, both values above returned using query -

select name items name 'search_term%' 

what want if user types 'bolt' space, bolt returned database.

effectively meaning last part of search term after space compared using like, results should match until last space.

i've tried:

select name items name 'search_term[a-z]%' 

but returns no results using above scenario.

is i'm after possible? i've tried explore using full text search have had no that. believe full text search enabled on name field, have limited experience this. query below didn't work.

select name items match(name) against('search_term') 

any advice or points appreciated.

the query

select name items name 'bolt %' 

doesn't return record, because both 'bolt' , 'bolts large' don't match 'bolt %'.

select name items name 'bolt%' 

returns both records, because both 'bolt' , 'bolts large' match 'bolt%'.

to 'bolt' , not 'bolts', must add space both search string , column string:

 select name items concat(name, ' ') 'bolt %' 

returns 'bolt' not 'bolts large'.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -