MySQL - Like Clause
MySQL 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.
Syntax
The syntax for the LIKE Condition in MySQL is:
expression LIKE pattern [ ESCAPE 'escape_character' ]
Expression :
A character expression such as a column or field.
pattern :
A character expression that contains pattern matching. The patterns that you can choose from are:
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.
SELECT * FROM studentinfo
WHERE StudentName LIKE 'S%';
StudentID | StudentName | Studentclass |
---|---|---|
5 | Sahayana | Sixth |
6 | Sweekrutha | Sixth |
SELECT StudentName
FROM studentinfo
WHERE StudentName LIKE 'Ajaa_hi';
--------RESULT---------
-------------------
| StudentName |
-------------------
| Ajaashi |
-------------------
MySQL - Grant_ Revoke Privilege
posted on 2019-11-26 23:15:04 - mysql Tutorials