0% found this document useful (0 votes)
5 views1 page

Basic SQL SELECT Query Examples

The document provides examples of basic SQL SELECT queries for retrieving data from a 'students' table. It covers selecting all columns, specific columns, using WHERE conditions, AND/OR operators, LIKE, BETWEEN, sorting with ORDER BY, and limiting results. Each example illustrates a different aspect of querying data effectively.

Uploaded by

shanne724
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views1 page

Basic SQL SELECT Query Examples

The document provides examples of basic SQL SELECT queries for retrieving data from a 'students' table. It covers selecting all columns, specific columns, using WHERE conditions, AND/OR operators, LIKE, BETWEEN, sorting with ORDER BY, and limiting results. Each example illustrates a different aspect of querying data effectively.

Uploaded by

shanne724
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Task 3: Writing Basic SELECT Queries

1. Select all columns from a table:

SELECT * FROM students;

2. Select specific columns:

SELECT name, age, grade FROM students;

3. Using WHERE condition:

SELECT * FROM students


WHERE grade = 'A';

4. Using AND and OR:

SELECT * FROM students


WHERE grade = 'A' AND age > 18;

SELECT * FROM students


WHERE grade = 'A' OR age > 18;

5. Using LIKE:

SELECT * FROM students


WHERE name LIKE 'A%';

6. Using BETWEEN:

SELECT * FROM students


WHERE age BETWEEN 18 AND 22;

7. Sorting with ORDER BY:

SELECT * FROM students


ORDER BY age ASC;

8. Limiting results:

SELECT * FROM students


ORDER BY age DESC
LIMIT 5;

You might also like