1

I want to search all fields from tables​​ tblproduct in MySQL database a given string, possibly using syntax as:

SELECT * FROM tblproduct WHERE * LIKE '%textbox%'

Is it possible to do something like this?

Marc Delisle
  • 8,760
  • 3
  • 27
  • 29
Mengky Chen
  • 63
  • 2
  • 9
  • you mean search on ALL columns – Pratik Aug 14 '15 at 05:56
  • 3
    its Full Text search. And this question is already answered here http://stackoverflow.com/questions/3797906/mysql-query-for-searching-through-all-the-fields – Pratik Aug 14 '15 at 05:57
  • `SELECT * FROM WHERE (CONVERT( USING utf8) LIKE '%textbox%' OR CONVERT( USING utf8) LIKE '%textbox%' OR .........`
    – Anant Kumar Singh Aug 14 '15 at 05:58
  • 1
    Check the technique shown in this answer: http://stackoverflow.com/questions/834912/sql-search-for-a-string-in-every-varchar-column-in-a-database – JorgeBPrado Aug 14 '15 at 05:58

1 Answers1

6

Try this..

concate fields to search whole table

Select * from tblproduct  where Concat(field1, '', field2, '', fieldn) like "%textbox%"

or

Using MATCH and AGAINST in mysql

SELECT * FROM tblproduct  WHERE MATCH (field1, field2, field3) AGAINST ('textbox')
Deenadhayalan Manoharan
  • 5,357
  • 14
  • 29
  • 48