Learn Python
Learn Data Structure & Algorithm
Learn Numpy
Learn Pandas
Learn Matplotlib
Learn Seaborn
Learn Statistics
Learn Math
Learn MATLAB
Learn Machine learning
Learn Github
Learn OpenCV
Learn Deep Learning
MySQL Introduction
MySQL Setup
MySQL Operators
MySQL Basic Works
MySQL Create Table
MySQL insert and get values
MySQL Condition
MySQL GROUP BY
MySQL Case
MySQL sorting and calculate avg,sum,count
MySQL Update
MySQL Time
MySQL String
MySQL Rollback & Commit
MySQL Join and Concatenate
MySQL Index
MySQL Date
MySQL View
MYSQL With Python
Learn MongoDB
Learn Web scraping
Learn Excel
Learn Power BI
Learn Tableau
Learn Docker
Learn Hadoop
You can use AND, OR, IN and NOT IN to set multiple condition
here we wanted books name whose id is less than 2
The LIKE operator is used in a WHERE clause. Like is used to search a specified pattern in a column.
There are two wildcards which are commonly used in the LIKE operator.
These wildcards are used to
define or create the pattern:
1. Percent sign (%): It represents zero or one or multiple characters.
2. Underscore sign (_): It represents one or single character
To create a pattern we can use % and _ separately and also together.
Let's see some example of patterns:
Pattern | Description |
---|---|
'e%' | Finds any values which start with "e" |
'%p' | Finds any values which end with "p" |
'h_%' | Finds any values which start with "h" and are at least 2 characters in length |
'z__%' | Finds any values which start with "z" and are at least 3 characters in length |
'%ra%' | Finds any values which have "ra" in any position |
'_s%' | Finds any values which have "s" in the second position |
'a%o' | Finds any values which start with "a" and ends with "o" |
Use of BINARY
If you normally write letters in a pattern then it is not case sensitive. Suppose you write letters in the
pattern in upper case and you want to get upper case pattern matched results then you have to write BINARY
between WHERE and column_name. For case-sensitive works use BINARY.
LIKE gives an output that contains the given pattern but NOT LIKE gives output exact opposite. It means NOT LIKE gives an output that doesn't contain the given pattern.
If you write asterisk(*) sign in that place where you wrote columns name then you will get all the column values in the output.
BINARY
If you normally write letters in a pattern then it is not case sensitive. Suppose you write letters in the
pattern in upper case and you want to get upper case pattern matched results then you have write BINARY
between WHERE and column_name. For case sensitive works use BINARY.
Suppose you wrote a query and according to the query you will get some output. Now the number of outputs can
be huge but you want to see some outputs among all the outputs.
For example, the actual number of number of outputs are 100 but you want to see or get only 10 outputs. In
this case, you will use limit and pass value 10. By doing this you will see only 10 outputs.
Because we used * sign that's why we will get all the columns but if you want some specific column then write those column names in the position of the asterisk (*) sign.