Contents
SQL LIKE Operator: Main Tips
- The operator LIKE is used inside a WHERE clause for searching specific patterns in columns.
- The operator LIKE is often used for search queries using keywords.
Syntax of SQL LIKE Operator
- Easy to use with a learn-by-doing approach
- Offers quality content
- Gamified in-browser coding experience
- The price matches the quality
- Suitable for learners ranging from beginner to advanced
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid Certificates of completion
- A wide range of learning programs
- University-level courses
- Easy to navigate
- Verified certificates
- Free learning track available
- University-level courses
- Suitable for enterprises
- Verified certificates of completion
SQL LIKE Operator: Demo Database
In this example we are using a basic SQL database.
Right here we have a section from the table called "Users":
ID | Username | Password | |
---|---|---|---|
1 | alfredfutter | [email protected] | secret1 |
2 | atrujillo | [email protected] | secret2 |
3 | moreno.antonio | [email protected] | secret3 |
4 | hardythomas | [email protected] | secret4 |
5 | bergluns | [email protected] | secret5 |
SQL LIKE Operator %: Examples
This statement will select every row from the table called "users", where email starts with an "a":
Note: Using "%" is for defining wildcards and can be used on either end of the keyword. In these examples, "%" on both sides means that the keyword may be a part of a longer text or word; placed on the left of the keyword it means that the keyword may be on the ending of another word; placed on the right of the keyword it means that the keyword may be in the beginning of another word.
This statement will select every row from the table called "users", where username ends with an "o":
This statement will select every row from the table called "users", where email contains the word "yahoo":
The keyword NOT reverses the logic, making the statement select the rows that do NOT contain the keyword you specified.
This statement will select every row from the table called "Users", where email does NOT contain the word "gmail":