What are the differences between using REGEXP and LIKE in MySQL queries?

When performing searches in MySQL queries, REGEXP allows for more complex pattern matching using regular expressions, while LIKE is simpler and more straightforward for basic pattern matching. REGEXP is more powerful and flexible but can be slower for large datasets, while LIKE is faster but has limited functionality.

// Using REGEXP in MySQL query
$query = "SELECT * FROM table_name WHERE column_name REGEXP 'pattern'";

// Using LIKE in MySQL query
$query = "SELECT * FROM table_name WHERE column_name LIKE '%pattern%'";