What are the potential pitfalls of using LIKE and "%" in a SELECT query in PHP?

Using LIKE and "%" in a SELECT query can lead to performance issues, especially when searching through a large dataset. It can cause the query to perform a full table scan, which can be slow. To improve performance, consider using full-text search indexes or optimizing your query to use more specific conditions.

// Example of using a full-text search index
$sql = "SELECT * FROM table_name WHERE MATCH(column_name) AGAINST ('search_term' IN NATURAL LANGUAGE MODE)";
$result = $conn->query($sql);