Sample Database Used in This Article

Let’s assume we have a table called users.

users

idnameemailagecitystatus
1Mrunalmrunal@test.com28PuneActive
2Priyapriya@test.com25MumbaiActive
3Amitamit@test.com31PuneInactive
4Snehasneha@test.com27DelhiActive
5Nehaneha@test.com30PuneActive

We’ll use this example throughout the article.


1. SELECT Query

The SELECT statement is one of the most important SQL commands for a QA Engineer.

It is used to retrieve data from a table.

Query

SELECT * FROM users;

This returns all columns and all records from the users table.

QA Use Case

Suppose you create a new user from the application.

After registration, you can run:

SELECT * FROM users;

and verify whether the user was inserted into the database.

Interview Tip

Be comfortable with SELECT. It is probably the SQL command you will use most frequently as a tester.


2. SELECT Specific Columns

You don’t always need every column.

You can select only the information you want.

SELECT name, email, city
FROM users;

This returns only:

Why is this useful for QA?

It makes large datasets easier to read.

For example, while validating registration functionality, you may only need:

SELECT name, email
FROM users;

3. WHERE Clause

The WHERE clause allows you to filter records.

SELECT *
FROM users
WHERE city = 'Pune';

This returns users whose city is Pune.

QA Scenario

Suppose your application contains a city filter.

The UI shows:

Pune — 3 users

You can verify the database using:

SELECT *
FROM users
WHERE city = 'Pune';

You can then compare the application result with the database result.


4. AND Condition

The AND operator allows you to apply multiple conditions.

SELECT *
FROM users
WHERE city = 'Pune'
AND status = 'Active';

This returns users who:

QA Scenario

Imagine an admin page has a filter:

City = Pune
Status = Active

You can validate the result using the above query.


5. OR Condition

OR is used when any one of multiple conditions can be true.

SELECT *
FROM users
WHERE city = 'Pune'
OR city = 'Mumbai';

This returns users from either Pune or Mumbai.

QA Scenario

Suppose the application allows users to select multiple cities.

You can verify whether the backend returns the correct records.


Pages: 1 2 3 4 5 6 7 8 9

Leave a Reply

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