DataDriven
LearnPracticeInterviewDiscussDaily
HelpContactPrivacyTermsSecurityiOS App

© 2026 DataDriven

Loading lesson...

  1. Home
  2. Learn
  3. Query Structure: Beginner

Query Structure: Beginner

Your first SQL query starts here

Your first SQL query — demystified

Category
SQL
Difficulty
beginner
Duration
9 minutes
Challenges
0 hands-on challenges

Topics covered: Tables, rows, and columns, SELECT and FROM basics, Selecting all columns (*), AS aliases for columns, Expressions in SELECT

Lesson Sections

  1. Tables, rows, and columns

    Inside each table in a database, information is organized into rows and columns. A row is a single record, such as one person, one order, or one product. A column is a type of information stored for every record, such as a name, a price, or a date. A cell is a single value, such as the name 'John' or the date 2025-10-12. Together, the rows and columns form a grid of cells much like a spreadsheet. You can look across a row to see all the details for one record, or down a column to see that type o

  2. SELECT and FROM basics (concepts: sqlSelectFrom)

    Every SQL query follows a predictable structure that tells the database what data you want and where to find it. Building Your First Query Understanding the role of each keyword helps you construct queries that retrieve exactly the data you need. SELECT Columns FROM Arrange the Query Check Your Understanding Selecting only the columns you need, rather than all columns, reduces the amount of data the database must read and transfer, which makes queries faster on large tables.

  3. Selecting all columns (*)

    The asterisk symbol provides a quick way to retrieve all columns without typing each name individually. When to Use * Choosing the Right Columns Now try selecting different columns from a product inventory table. Requesting only the columns relevant to your question means analysts reading your query can immediately understand what data you care about without scrolling through irrelevant output. The ability to select any combination of columns from a table is one of the core reasons SQL is so fle

  4. AS aliases for columns

    Aliases let you create readable, descriptive names for columns and tables without changing the underlying data. When you use an alias, the underlying table and its data remain unchanged. The alias only affects how the data is labeled in your query and results. Toggle between the examples below to see each type. Practical Aliasing Production databases often have column names like usr_cre_dt or prc_usd_base that save keystrokes when engineers build the schema but confuse everyone reading queries l

  5. Expressions in SELECT

    Expressions transform data on the fly, letting you compute totals, differences, and other derived values directly in your query. An expression is any combination of values, operators, and functions that the database evaluates to produce a result. For example, "price + tax" is an expression that adds two column values together. SQL can calculate new values as part of the results using expressions. Common Operations SQL supports standard arithmetic operators that let you perform calculations direc

Related

  • All Lessons
  • Practice Problems
  • Mock Interview Practice
  • Daily Challenges