Search a whole table in mySQL for a string

后端 未结 8 1591
孤城傲影
孤城傲影 2020-12-14 01:13

I\'m trying to search a whole table in mySQL for a string.

I want to search all fields and all entrees of a table, returning each full entry that contains the speci

8条回答
  •  囚心锁ツ
    2020-12-14 01:47

    Identify all the fields that could be related to your search and then use a query like:

    SELECT * FROM clients
    WHERE field1 LIKE '%Mary%'
       OR field2 LIKE '%Mary%'
       OR field3 LIKE '%Mary%'
       OR field4 LIKE '%Mary%'
       ....
       (do that for each field you want to check)
    

    Using LIKE '%Mary%' instead of = 'Mary' will look for the fields that contains someCaracters + 'Mary' + someCaracters.

提交回复
热议问题