MYSQL
June 3, 2026 3 min read

MYSQL Operators and Keywords: LIMIT, LIKE, IN, and BETWEEN for Advanced Querying

HS
HEMANT SINGH
Technical Writer & Educator

For these operators and keywords, we will take this given table as an example.

Table: posts

idtitlepost
1What is a computer?Electronic machine
2An input deviceKeyboard
3WWW stands forWorld wide web

LIMIT

LIMIT specifies how many records will fetch in a query.

Display only one record after record that has id 2.

SELECT * FROM posts LIMIT 2, 1;

WHERE the first number defines the skip and the second number defines how many records will display.

Table: posts

idtitlepost
3WWW stands forWorld wide web

LIKE

Like operator is used to search any pattern in records.

There are wildcards used with LIKE keywords.

  • % - Represents zero, one, and multiple matched characters
  • _ - underscore represents one character.

Find all those posts whose title start with "w"

SELECT * FROM posts WHERE title LIKE 'w%'

Table: posts

idtitlepost
1What is a computer?Electronic machine
3WWW stands forWorld wide web

Find all those posts whose title end with "r"

SELECT * FROM posts WHERE title LIKE '%r';

Table: posts

idtitlepost
3WWW stands forWorld wide web

Find all those posts whose titles contain "i"

SELECT * FROM posts WHERE title LIKE '%i%';

Table: posts

idtitlepost
1What is a computer?Electronic machine
2An input deviceKeyboard

Find all those posts whose title start with 'a' and contain 2 characters

SELECT * FROM posts WHERE title LIKE 'a_%';

Table: posts

idtitlepost
2An input deviceKeyboard

For IN and BETWEEN operators, the given table will be taken as an example.

Table: products

idproduct_namepriceqty
1UPS30002
2PEN1002
3MOUSE4001
4SPEAKER50002

 

In Operator

It is a shorthand for the OR operator, it allows to use of multiple values in the WHERE clause.

Fetch only those records which have id 1,2,4.

SELECT * FROM products WHERE id IN(1, 2, 4);

Table: products

idproduct_namepriceqty
1UPS30002
2PEN1002
4SPEAKER50002

BETWEEN Operator

When we want to fetch all those records whose price between in a given range.

Fetch all those records whose prices are between 1000 to 5000.

SELECT * FROM products WHERE price BETWEEN 1000 AND 5000;

Table: products

idproduct_namepriceqty
1UPS30002
4SPEAKER50002