MySQLi Like

MySQLi LIKE condition allows wildcards to be used in the WHERE clause of a SELECT, INSERT, UPDATE, or DELETE statement. This allows you to perform pattern matching.

Below the syntax of LIKE condition.

expression LIKE [ ESCAPE 'escape_character' ]
<?php
$conn  = mysqli_connect('localhost:3306', 'user_name', 'password', 'db_nexladder');
 if(! $conn) {
     die('Could not connect: ' . mysqli_error());
 }
$sql = "SELECT `first_name` FROM `tbl_customers` WHERE `first_name` LIKE 'A%'";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) 
  {
    while($row = mysqli_fetch_object($result)) {
      echo "Name: " . $row->first_name. "<br />";
     }
  } else {
     echo "0 rows";
}
 mysqli_close($conn);
?>

Parameters:

Wildcard Explanation
% Allows you to match any string of any length (including zero length)
_ Allows you to match on a single character

escape_character - Optional. It allows you to test for literal instances of a wildcard character such as % or _. If you do not provide the escape_character, MySQL assumes that "" is the escape_character.

Below it'll look like:

mysql like