php - Trouble with MySQL: CONCAT_WS(' ', name_first, name_middle, name_last) like '%keyword%' -


O people, I am setting up a keyword search in many areas: name_first, name_middle, name_last, but I can not find The result I want to query here is:

  "SELECT accounts_users.user_ID, users.name_first, users.name_middle, users.name_last, users.company FROM accounts_users, user where accounts_users.account_ID = $ Account_ID 'and accounts_users .user_id = users.id and CONCAT_WS (' ', users.name_first, users.name_middle, users.name_last)' $ user_keyword% 'by ORDER users .name_first ASC " 

Therefore, if I get three names in DB:

Aaron J. Baan
Aaron J. Cab - Bob L. Loblob

And if user_keyword == "Bob Lobock" I did not find any results if user_keyword == "Bob L" then it gives Bob L. Lockblow. Obviously I can not force people to include names between people in my keyword search, but I am stuck in a proper manner to do this.

All help is greatly appreciated.

Try to create a full text index on those 3 columns, and then a full text on it Searching.

## UPDATE ##

If using INNODB, then maybe the string on the Use the split function;

  $ myVars = split ("", $ user_keyword);  

Then add a selection statement for each word (I will also use the connectivity statement in the selection statement, so that you do not take it everywhere for a statement)

  $ additional SQL = ''; Forex Currency ($ myVars $ Search) {$ extraSQL} '%' Like '=' and 'my_concat` $ Search. "% '"; } Select `your_fields`, CONCAT_WS ('', users.name_first, users.name_middle, users.name_last) as` my_concat` as `your_tables` where` accounts_users`.account_ID = '$ account_ID' $ ExtraSQL;  

Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -