LIKE Operator The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. The LIKE keyword is used to select rows containing columns that match a wildcard pattern. There are two wildcards Percent ( % ) Underscore ( _ )
Percent ( % ) Syntax: SELECT * / columnnames FROM table_name WHERE columnname Like “% character%” ; The percent sign represents multiple characters. The % character matched any substring. Example: SELECT * FROM Employee WHERE names Like “ a%” ;
Underscore ( _ ) Syntax: SELECT * / columnnames FROM table_name WHERE columnname Like “_ character _” ; The underscore represents a single character. The _ character matches any character. Example: SELECT * FROM Employee WHERE names Like “ s_ _ _” ;
Combination Of both Operator Syntax: SELECT * / columnnames FROM table_name WHERE columnname Like “%_character_ %” We can use both operator in MySql Query Example: SELECT * FROM Employee WHERE names Like “ _ a%a _” ;