I’m making my search function but I don’t know how to select only rows that contain the search terms. The idea would be to select only rows with the string $search from the table lines in the column “Text”. How could I do it? Thanks
I’m making my search function but I don’t know how to select only rows
Share
I don’t recommend to use
LIKEto solve substring or keyword searches, because that forces a table scan and cannot be improved by an index. Which means as your table grows, it will run hundreds or thousands of times slower than a solution using fulltext indexing.MySQL supports a FULLTEXT index type, but it only works in MyISAM (currently). Read about how to
CREATE FULLTEXT INDEXand how to use FULLTEXT index functionsMATCH() AGAINST().Most people use Sphinx Search or Apache Solr for fulltext indexing, as a complementary technology for MySQL.
See also my presentation Practical Full-Text Search in MySQL or my book SQL Antipatterns Volume 1: Avoiding the Pitfalls of Database Programming.