1
votes

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?

1
you mean search on ALL columns - Pratik
its Full Text search. And this question is already answered here stackoverflow.com/questions/3797906/… - Pratik
SELECT * FROM <table name> WHERE (CONVERT(<column name> USING utf8) LIKE '%textbox%' OR CONVERT(<column name> USING utf8) LIKE '%textbox%' OR ......... - Anant Kumar Singh
Check the technique shown in this answer: stackoverflow.com/questions/834912/… - JorgeBPrado

1 Answers

6
votes

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')