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
SELECT * FROM users WHERE email LIKE '%gmail%';
- Simplistic design (no unnecessary information)
- High-quality courses (even the free ones)
- Variety of features
- Nanodegree programs
- Suitable for enterprises
- Paid certificates of completion
- Professional service
- Flexible timetables
- A variety of features to choose from
- Professional certificates of completion
- University-level courses
- Multiple Online degree programs
- Great user experience
- Offers quality content
- Very transparent with their pricing
- Free certificates of completion
- Focused on data science skills
- Flexible learning timetable
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":
SQL LIKE Operator %: Examples
This statement will select every row from the table called "users", where email starts with an "a":
SELECT * FROM users WHERE email LIKE '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":
SELECT * FROM users WHERE username LIKE '%o';
This statement will select every row from the table called "users", where email contains the word "yahoo":
SELECT * FROM users WHERE email LIKE '%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":
SELECT * FROM users WHERE email NOT LIKE '%gmail%';
Latest Udacity Coupon Found:
75% OFF COURSES
Udacity Black Friday Offer
The best time to save on Udacity courses is now - follow this coupon to access a 75% Udacity Black Friday discount & enjoy learning at a very low cost!