Find column that contains a given value in MySQL

前端 未结 3 1368
太阳男子
太阳男子 2021-01-26 19:10

I have a table in a MySQL database. I am given a value that occurs as a cell value in that table but I do not know which cell is it i.e. the row and column of that cell. What is

3条回答
  •  离开以前
    2021-01-26 19:46

    Without knowing more about your app, you have several options:

    • Use MySQL's built-in full-text search. You can check the MATCH function in the MySQL documentation.
    • Depending on the needs of your app you could decide to index your whole table with an external full-text search index, like Solr or Sphynx. This provides instant response time, but you'll need to keep the index updated.
    • You can loop through all the columns in the table doing a LIKE query in MySQL (very expensive in CPU and time)

提交回复
热议问题