#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
Step 2
4 min read

Basic SQL Syntax

Write your very first SQL command in 5 minutes!

What is SQL?

SQL stands for Structured Query Language.

It's how you talk to a database. You write commands, and the database gives you data.

Your First SQL Command

Here's the simplest SQL command:

SELECT * FROM students;

What does this mean?

  • SELECT = "Show me"
  • ***** = "everything"
  • FROM = "from this table"
  • students = the table name
  • ; = end of command

In simple English: "Show me everything from the students table"

The Basic Pattern

Every SQL command follows this pattern:

SELECT (what you want) FROM (which table)

Examples:

SELECT * FROM students; SELECT name FROM students; SELECT name, age FROM students;

3 Simple Rules

Rule 1: End every command with semicolon (;)

Rule 2: SQL keywords (SELECT, FROM) can be uppercase or lowercase

Rule 3: Spaces don't matter - write it however you like

These are all the same:

SELECT * FROM students; select * from students; SELECT * FROM students;

Common Mistakes to Avoid

Forgetting the semicolon:

SELECT * FROM students -- Wrong! SELECT * FROM students; -- Correct!

Misspelling keywords:

SELCT * FROM students; -- Wrong! SELECT * FROM students; -- Correct!

Try It Yourself!

Use the playground below to run your first SQL command.

What's Next?

You just wrote your first SQL command! Next, let's learn the most important SQL keywords.

Question 1: Show all students from the table

Write a query to display all columns and all rows from the students table.

SQL Editor
Loading...
Output

Click "Run Query" to see results

Question 2: Show only name and age

Modify the query to show only the name and age columns. Try changing "age" to "grade" and run again!

SQL Editor
Loading...
Output

Click "Run Query" to see results

Finished this topic?

Mark it complete to track your progress and maintain your streak!

SkillsetMaster - AI, Web Development & Data Analytics Courses