Master the Basics of SQL
Learn about Syntax, Command, Types, Queries, and Projects
SQL isn’t just a tool it’s a language every data professional speaks. Whether you’re analyzing trends, building predictive models, or managing data pipelines, SQL plays a key role at every step. SQL helps you extract insights, clean messy data, and make sense of complex datasets. From writing simple queries to handling massive databases, SQL is the bridge between raw data and real-world decisions. That’s why SQL remains one of the most in-demand skills across the data industry.
What is SQL?
SQL stands for Structured Query Language. It is a standardized language used to manage and manipulate relational databases. SQL allows users to:
- Store, retrieve, and update data efficiently
- Perform calculations, filtering, and aggregation
- Build connections between multiple tables through joins
- Extract useful insights from large volumes of structured data
In short, SQL helps transform raw data into meaningful information, a skill that’s invaluable for anyone in data science, analytics, or business intelligence.
SQL Syntax Basics
Understanding SQL basics starts with mastering its basic syntax. SQL statements follow a simple structure that includes keywords, clauses, expressions, and identifiers.
Example:
SELECT name, age FROM employees WHERE age > 30 ORDER BY age DESC;
- SELECT: keyword to retrieve data
- name, age: columns to retrieve
- FROM employees: table name
- WHERE: filter condition
- ORDER BY: sorting instruction
This human-readable format is what makes SQL beginner-friendly.
Types of SQL Commands: DDL, DML, DCL, TCL, and DQL
SQL commands are grouped based on their function:
1. DDL (Data Definition Language)
Used to define or change the structure of database objects like tables.
CREATE, ALTER, DROP, TRUNCATE
2. DML (Data Manipulation Language)
Used to manage data within tables.
SELECT, INSERT, UPDATE, DELETE
3. DCL (Data Control Language)
Used to control access to data.
GRANT, REVOKE
4. TCL (Transaction Control Language)
Manages transactions within databases.
COMMIT, ROLLBACK, SAVEPOINT
5. DQL (Data Query Language)
Focused solely on querying data.
SELECT
Knowing these command types helps you understand what you’re trying to achieve when writing any SQL statement.
Data Types in SQL
When creating tables, you must define what type of data each column will hold. Common SQL data types include:
INT: Integer values
FLOAT or DECIMAL: Decimal numbers
VARCHAR(n): Variable-length character string
CHAR(n): Fixed-length string
DATE: Date values
BOOLEAN: True/False values
TEXT: Long strings
Choosing the right data type improves storage efficiency and query performance.
Basic SQL Queries (SELECT, WHERE, ORDER BY, etc.)
Query Type | Purpose | Example |
---|---|---|
SELECT | Fetch data | SELECT * FROM employees; |
WHERE | Filter records | SELECT * FROM employees WHERE salary > 50000; |
ORDER BY | Sort results | SELECT * FROM employees ORDER BY age DESC; |
GROUP BY | Group data | SELECT department, COUNT(*) FROM employees GROUP BY department; |
HAVING | Filter grouped data | SELECT department, AVG(salary) FROM employees GROUP BY department HAVING AVG(salary) > 60000; |
DISTINCT | Remove duplicates | SELECT DISTINCT department FROM employees; |
INSERT INTO | Add new data | INSERT INTO employees (name, age) VALUES ('John', 30); |
UPDATE | Modify existing data | UPDATE employees SET age = 31 WHERE name = 'John'; |
DELETE | Remove records | DELETE FROM employees WHERE name = 'John'; |
JOIN | Combine tables | SELECT * FROM orders JOIN customers ON orders.customer_id = customers.id; |
LEFT JOIN | Keep all records from left table | SELECT * FROM A LEFT JOIN B ON A.id = B.id; |
RIGHT JOIN | Keep all records from right table | SELECT * FROM A RIGHT JOIN B ON A.id = B.id; |
INNER JOIN | Keep matched records only | SELECT * FROM A INNER JOIN B ON A.id = B.id; |
UNION | Merge result sets | SELECT name FROM A UNION SELECT name FROM B; |
BETWEEN | Range filtering | SELECT * FROM employees WHERE salary BETWEEN 50000 AND 80000; |
IN | Match multiple values | SELECT * FROM employees WHERE department IN ('HR', 'Finance'); |
LIKE | Pattern matching | SELECT * FROM employees WHERE name LIKE 'J%'; |
These queries form the foundation of SQL and are essential for interview preparation and real-world problem solving.
Sorting Results Using ORDER BY
The ORDER BY clause helps sort the results in ascending or descending order.
Example:
SELECT * FROM employees ORDER BY salary DESC;
You can sort by one or multiple columns and customize the sort order easily.
Using Logical Operators (AND, OR, NOT)
Logical operators help build more complex conditions within the WHERE clause.
AND
Both conditions must be true:
SELECT * FROM employees WHERE department = ‘Sales’ AND salary > 60000;
OR
At least one condition must be true:
SELECT * FROM employees WHERE department = ‘HR’ OR department = ‘Finance’;
NOT
Negates a condition:
SELECT * FROM employees WHERE NOT department = ‘IT’;
These operators help in writing dynamic and flexible queries.
Build SQL Skills with Projects and Tools
Learning SQL isn’t enough you must apply it. Work on real projects such as:
Customer segmentation analysis
Sales performance dashboards
Employee attrition prediction using SQL
And practice using popular tools like:
MySQL Workbench
PostgreSQL
SQLite
Google BigQuery
Microsoft SQL Server
These tools are widely used in companies, and practicing on them gives you real-world exposure.
Learn SQL the Right Way with INTTRVU.AI
At INTTRVU.AI, we offer a full-stack Data Science and AI Course that integrates:
SQL learning from beginner to advanced
Hands-on database projects
Resume and interview preparation
Mock interviews for real-world readiness
If you’re looking to build a career in data science, mastering data science with SQL is non-negotiable and INTTRVU.AI is here to help you every step of the way.
Learn Python, work on Machine Learning projects, and strengthen your core programming fundamentals.
Learn About Trending Topic