
Basic SQL Syntax: SELECT, FROM, WHERE –
Introduction
If you’re just starting with SQL, one of the first things you’ll learn is how to retrieve data from a table using three fundamental keywords:
SELECT
FROM
WHERE
These form the core of almost every SQL query. In this blog post, we’ll break down how each part works, provide real-world examples, and explain how to use them in SQL Server and Power BI environments.
Why Learn SQL Basics?
Learning SELECT
, FROM
, and WHERE
gives you the power to:
- Retrieve specific data from massive databases
- Filter records based on conditions
- Use this data in tools like Power BI for reporting
Want to apply SQL in live projects?
Join Our Data Analytics Course
1. The SELECT Clause
The SELECT
clause tells SQL which columns you want to retrieve.
Basic Syntax:
sqlCopyEditSELECT column1, column2
FROM table_name;
Example:
sqlCopyEditSELECT FirstName, LastName
FROM Employees;
This returns only the FirstName
and LastName
from the Employees
table.
Pro Tip: Use SELECT *
to select all columns from the table.
2. The FROM Clause
The FROM
clause specifies which table you want to get the data from.
Example:
sqlCopyEditSELECT *
FROM Products;
This pulls all columns from the Products
table.
Tables come from your SQL database, often organized under schemas like dbo.Products
.
3. The WHERE Clause
The WHERE
clause filters records based on specific conditions.
Syntax:
sqlCopyEditSELECT column1
FROM table_name
WHERE condition;
Example:
sqlCopyEditSELECT Name, Salary
FROM Employees
WHERE Salary > 50000;
🔎 This returns names of employees who earn more than 50,000.
More condition examples:
Condition | Use |
---|---|
= | Equal to |
> / < | Greater or less than |
BETWEEN | Range |
LIKE | Pattern match |
IN | Matches any value in a list |
Putting It All Together
Example Query:
sqlCopyEditSELECT Name, Age
FROM Students
WHERE Age BETWEEN 18 AND 25;
This query returns names and ages of students aged between 18 and 25.
Try this inside SQL Server Management Studio (SSMS) or your preferred SQL tool.
Learn to use queries directly in Power BI with real-time dashboards.
Common Mistakes to Avoid
- Don’t forget the semicolon
;
at the end (especially in multi-query scripts) - Use correct column names – SQL is case-insensitive, but spelling must match
- Avoid
SELECT *
in production – it’s better to choose specific columns for performance
Real-World Use Case in Power BI
Suppose you want to analyze orders only from India in Power BI.
Your SQL query might look like:
sqlCopyEditSELECT OrderID, CustomerName, Country
FROM Orders
WHERE Country = 'India';
This helps you filter data before importing it into Power BI, saving memory and improving performance.
Practice this live in our hands-on Data Analytics Training
Summary
Clause | Purpose | Example |
---|---|---|
SELECT | Columns to display | SELECT Name |
FROM | Table to query | FROM Employees |
WHERE | Filter results | WHERE Age > 30 |
Final Thoughts
Mastering these three SQL clauses — SELECT
, FROM
, and WHERE
— is your first step to becoming a data professional. These form the foundation of everything you’ll write in SQL, and they translate directly to what you’ll use in Power BI, data dashboards, and reporting tools.
Ready to move from beginner to pro?
Join the Data Analytics Course Now
Need 1-on-1 SQL Mentoring? Contact Us
Tag:MICROSOFT SQL, MS SQL Server, SQL, SQL Data