As we know that wildcards are characters that help search data matching complex criteria. Wildcards are used in conjunction with LIKE comparison operator or NOT LIKE comparison operator. MySQL allows us to match the data, from the output of CONCAT() function, with the help of wildcard and comparison operators LIKE or NOT LIKE. An example from ‘Student’ table is given to make it clearer.
Example
mysql> Select CONCAT(Name,' ', Last_name) AS NAME from student Where CONCAT(Name, ' ',Last_Name) LIKE '%Kumar%'; +---------------+ | NAME | +---------------+ | Gaurav Kumar | | Harshit Kumar | +---------------+ 2 rows in set (0.00 sec) mysql> Select CONCAT(Name,' ', Last_name) AS NAME from student Where concat(Name, ' ',Last_Name) NOT LIKE '%Kumar%'; +----------------+ | NAME | +----------------+ | Aarav Sharma | | Gaurav Rathore | | Yashraj Singh | +----------------+ 3 rows in set (0.00 sec)
From the above two result sets, it is clear that how wildcard characters can be used with CONCAT() function.