MySQL search a text from two columns

Posted by I Like PHP on Stack Overflow See other posts from Stack Overflow or by I Like PHP
Published on 2010-03-27T14:57:58Z Indexed on 2010/03/27 15:03 UTC
Read the original article Hit count: 205

Filed under:
|

i have a table (tbl_world) which look like this

  id | first_name | last_name | age | class |

now i want to search the text which can be anywhere in first_name or in last_name

i m using below mysql query

 "SELECT * FROM tbl_world WHERE REGEXP '".$word."' IN( first_name, last_name)";

where $word is user input (means if i search 'hell' then 'hello' as well as 'wellhell' also returned in result)

above query display error, please suggest me optimize method for search in mysql.

addition question: should i use LIKR or RLIKE?

© Stack Overflow or respective owner

Related posts about mysql

Related posts about regex