Basic SQL Queries – Learn SQL with Simple Examples
SQL / Database

Basic SQL Queries – Learn SQL with Simple Examples

27 Aug, 2026 CCI Admin SQL / Database
Back to All Blogs

Basic SQL Queries – Learn SQL with Simple Examples

Published: 27 Aug, 2026 | Author: CCI Admin | Category: SQL

SQL is an essential skill for anyone interested in software development, web development, data management, or database administration. SQL queries allow us to create, store, retrieve, update, and delete information in a database.

What is SQL?

SQL stands for Structured Query Language. It is used to communicate with relational databases and manage the data stored inside them.

Popular relational databases such as MySQL, PostgreSQL, Oracle Database, and Microsoft SQL Server use SQL to work with data.

What is a Database?

A database is an organized collection of information. For example, a student management system can store student names, ages, courses, marks, and attendance information in database tables.

Basic SQL Commands

Some of the most commonly used SQL commands are:

  • CREATE – Creates a database or table.
  • INSERT – Adds new records.
  • SELECT – Retrieves records.
  • UPDATE – Modifies existing records.
  • DELETE – Removes records.

1. CREATE TABLE

The CREATE TABLE command is used to create a new table in a database.

CREATE TABLE students (
    id INT,
    name VARCHAR(50),
    age INT,
    course VARCHAR(50)
);

This example creates a students table with four columns.

2. INSERT Data

The INSERT INTO command is used to add new records to a table.

INSERT INTO students (id, name, age, course)
VALUES (1, 'Arun', 20, 'Python');

We can insert another student using the same command.

INSERT INTO students (id, name, age, course)
VALUES (2, 'Priya', 21, 'Java');

3. SELECT Data

The SELECT command is used to retrieve information from a table.

SELECT * FROM students;

The * symbol means that we want to retrieve all columns.

We can also select specific columns:

SELECT name, course
FROM students;

4. WHERE Clause

The WHERE clause is used to retrieve records that match a specific condition.

SELECT * FROM students
WHERE age = 20;

This query displays students whose age is 20.

5. UPDATE Data

The UPDATE command is used to modify existing records.

UPDATE students
SET course = 'Java'
WHERE id = 1;

This changes the course of the student whose ID is 1.

6. DELETE Data

The DELETE command is used to remove records from a table.

DELETE FROM students
WHERE id = 2;

This removes the student whose ID is 2.

Always use a suitable WHERE condition when deleting specific records.

7. ORDER BY

The ORDER BY clause is used to sort query results.

SELECT * FROM students
ORDER BY name ASC;

ASC sorts the results in ascending order. We can use DESC for descending order.

8. DISTINCT

The DISTINCT keyword is used to display only unique values.

SELECT DISTINCT course
FROM students;

This query displays each course only once.

9. COUNT()

The COUNT() function can be used to count records.

SELECT COUNT(*) AS total_students
FROM students;

This query returns the total number of students in the table.

Simple Real-World Example

Imagine a student management system where student information is stored in a database. We can use SQL queries to add students, display student details, update courses, search for students, and remove records.

SELECT name, course
FROM students
WHERE course = 'Java';

This query finds students who are enrolled in the Java course.

Why Learn Basic SQL Queries?

  • SQL is widely used in software applications.
  • It helps developers work with databases.
  • It is important for web and application development.
  • It helps retrieve and manage large amounts of data.
  • SQL is useful for developers, testers, analysts, and database professionals.

Tips for SQL Beginners

  • Start with SELECT queries.
  • Practice INSERT, UPDATE, and DELETE commands.
  • Learn how WHERE conditions work.
  • Practice using ORDER BY and DISTINCT.
  • Understand primary keys and relationships.
  • Practice SQL using a small real-world database.
  • Always be careful when using UPDATE and DELETE.

Learn SQL Through Practical Training

At CCI Computer Education, Pudukkottai, students can learn SQL and database concepts through simple explanations, practical queries, coding exercises, and real-world projects.

Beginners can start with SQL fundamentals and gradually learn database design, primary keys, foreign keys, relationships, joins, functions, subqueries, and database connectivity with programming languages.

Conclusion

Basic SQL queries are the foundation for working with relational databases. Learning commands such as SELECT, INSERT, UPDATE, DELETE, CREATE, WHERE, and ORDER BY will help beginners understand how applications communicate with databases.

Start with simple queries, practice regularly, and gradually work with real-world database projects to improve your SQL skills.

What's Next?

In our next SQL tutorial, we will explore SQL Joins and learn how to retrieve related data from multiple tables.


Call: 98427 97945  |  Website: ccipudukkottai.com  |  WhatsApp Channel: Join Now

Share: Facebook | WhatsApp | Twitter