top 10 Free SQL Practice Queries for Beginners in 2025 (With Examples & Exercises)

Top 10 Free SQL Practice Queries for Beginners in 2025 (With Examples & Exercises)

 

Querying with SQL Comparison Operators :

Database :

The database contains a Player table that stores the data of Players like name, age, score.

Cricketer Performance Player Table

Name Age Score
Virat 32 60
Rohit 39 55
Dhoni 44 80
Raina 35 48
Gill 24 75
Rahul 30 58
Surya 31 69
Iyer 28 62
Pant 27 53
Jadeja 36 70
Bumrah 30 65

 

Comparison Operators :

SQL Comparison Operators

Operator Description
= Equal to
<> Not equal to
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to

 

compare two rows in SQL step by step :

  1. Get all the details of the Player whose is 30 from the Player table.
SELECT
*
FROM
Player
WHERE
Age = 30;

Output :

Name Age Score
Rahul 30 58
Bumrah 30 65

2. Get all the details of the Player that Greater than or equal to 60 Score from the Player table.

SELECT
*
FROM
Player
WHERE
Score >= 60;

 Output :

Name Age Score
Virat 32 60
Dhoni 44 80
Gill 24 75
Surya 31 69
Iyer 28 62
Jadeja 36 70
Bumrah 30 65

Similarly you can use other comparison operators like Greater than (>), Not equal to(<>), Less than (<), less than or equal to(<=) its operators help you retrieve  only the rows that match your required values in a SQL query.

What are string operations in SQL?

Consider the case of ecommerce platforms. User typically search for product using keywords like typing “mobile” in search bar will fetch thousands of results. So how to do SQL queries retrieve such partial matches? That’s where string operations come in, let’s learn about it!

Let’s imagine we have a table called product that stores details loke :

  • Product Name
  • Category
  • Price
  • Brand
  • Rating
Name Category Price Brand Rating
Smart Watch Gadgets 17000 Apple 4.9
Smart Cam Gadgets 2600 Realme 4.7
Smart TV Gadgets 40000 Sony 4.0
Realme Smart Band Gadgets 3000 Realme 4.6
Bourbon Small Food 10 Britannia 3.9
Bourbon Special Food 15 Britannia 4.6
Bourbon With Extra Cookies Food 30 Britannia 4.4
Blue Shirt Clothing 750 Denim 3.8
Black Jeans Clothing 950 Denim 4.5
Sports Shoes Footwear 2200 Nike 4.2
Running Shoes Footwear 3200 Adidas 4.3
Formal Shoes Footwear 2800 Bata 3.9
Bluetooth Earbuds Gadgets 3500 Boat 4.1
Wireless Mouse Accessories 799 Logitech 4.2
Noise Cancelling Headphones Gadgets 8999 Sony 4.8

What is the like operator in SQL?:

LIKE operator is used to perform Queries  on string.  It’s commonly used in the WHERE clause to filter records based on matches.

we write patterns, SQL uses wildcard characters:

Symbol Description Example
% (percent) Matches zero or more characters ch% → matches “Bl”, “Blue Shirt”, “Black Jeans”
_ (underscore) Matches exactly one character _mart → matches “Smart Watch”, “Smart Cam”

What is used for pattern matching in SQL?:

Pattern Type Example What It Does
Exact Match WHERE name LIKE ‘Smart’ Finds rows where name is exactly “Smart”
Starts With WHERE name LIKE ‘Smart%’ Finds names starting with “Smart”
Ends With WHERE name LIKE ‘%Smart’ Finds names ending with “Smart”
Contains WHERE name LIKE ‘%Smart%’ Finds names that contain “Smart” anywhere
Pattern Length WHERE name LIKE ‘S_%’ Finds names that start with “S” and are at least 2 characters long

What is the syntax for like in SQL?

SELECT *
FROM table_name
WHERE column_name LIKE matching_pattern;

like operator in SQL example:

Get all the products in the “Gadgets” category from the product table.

SQL Query:

SELECT *
FROM product
WHERE category LIKE “Gadgets“;

Like operator OUTPUT :

Name Category Price Brand Rating
Smart Watch Gadgets 17000 Apple 4.9
Smart Cam Gadgets 2600 Realme 4.7
Smart TV Gadgets 40000 Sony 4.0
Realme Smart Band Gadgets 3000 Realme 4.6
Bluetooth Earbuds Gadgets 3500 Boat 4.1
Noise Cancelling Headphones Gadgets 8999 Sony 4.8

like operator in SQL example:

Get all the products in the “Blue%” category from the product table.

SQL Query:

SELECT *
FROM product
WHERE category LIKE “Blue%”; 

OUTPUT :

Name Category Price Brand Rating
Blue Shirt Clothing 750 Denim 3.8

Note :

  • Use % when you’re not sure about the length of the string.
  • Use _ when you known the exact length or position of characters.

what are the different types of logical operators explain with example :

Operator Description
AND Returns rows only when all conditions are true
OR Returns rows if at least one condition is true
NOT Negates the condition (returns rows where the condition is false)

logical operators syntax in sql :

SELECT *
FROM product
WHERE condition1 [AND|OR|NOT] condition2;

Logical operators SQL query :

SELECT *
FROM product
WHERE category = ‘Clothing’ AND price >= 700;

OUTPUT :

Name Category Price Brand Rating
Black Jeans Clothing 950 Denim 4.5

 

What is the correct order of operator precedence in SQL?

  1. NOT— Evaluated first
  2. AND–Evaluated second.
  3. OR— Evaluated last

what is the difference between in and between operators in SQL with example :

Data base : The database a product table.

What is an in operator in SQL?

Check if a column value exists within a specific list.

Syntax :

SELECT *
FROM product
WHERE brand IN (‘Realme’, ‘Mufti’, ‘Apple’, ‘Denim’);

 

Name Category Price Brand Rating
Smart Watch Gadgets 17000 Apple 4.9
Smart Cam Gadgets 2600 Realme 4.7
Realme Smart Band Gadgets 3000 Realme 4.6
Blue Shirt Clothing 750 Denim 3.8
Black Jeans Clothing 950 Denim 4.5

 

What is the between operator in SQL?

Check if a value is within a given range.

what is the between operator syntax in sql :

SELECT *
FROM product
WHERE price BETWEEN 2600 and 10000;

OUTPUT :

Name Category Price Brand Rating
Smart Cam Gadgets 2600 Realme 4.7
Realme Smart Band Gadgets 3000 Realme 4.6
Bluetooth Earbuds Gadgets 3500 Boat 4.1
Noise Cancelling Headphones Gadgets 8999 Sony 4.8

 

Share your love
kashikummari@gmail.com
kashikummari@gmail.com
Articles: 12

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Your email address will not be published. Required fields are marked *