Ch 1: SQL Basics & Syntax

About This Chapter

Study this tutorial chapter to learn the basics and syntax of SQL. You'll learn about the basic elements of the programming language and understand what queries, subqueries and statements do.

SQL Basics & Syntax: Chapter Summary

Learn the basics and syntax of the SQL programming language with these short and engaging tutorial lessons. You'll learn the basic elements of the programming language, including queries and subqueries, and become educated on the applications of concepts such as joins, cursors, injection, parameterized queries and more. Our expert SQL instructors break down SQL definitions and explain their applications through step-by-step examples. You can also take the short self-assessment quizzes that follow each lesson to make sure you fully understand these SQL concepts.

These lessons will help you:

  • Know basic SQL query syntax
  • Recognize examples of subqueries and parameterized queries
  • Understand inner, left and right, full outer, cross and self-joins
  • Differentiate between UNION and JOIN, as well as PIVOT and UNPIVOT
  • Explain GROUP BY clause
  • Define cursors in SQL
  • Prevent SQL injection

13 Lessons in Chapter 1: SQL Basics & Syntax
Test your knowledge with a 30-question chapter practice test
Basic SQL Query Syntax

1. Basic SQL Query Syntax

In this lesson, we will describe SQL queries and how these queries are used to access data stored in a relational database. We will also discuss SQL statements and the SQL clauses used to construct these statements.

SQL Subqueries: Example & Definition

2. SQL Subqueries: Example & Definition

We live in a world of data: It's no longer uncommon to see databases that exceed ten million lines of information! Getting data out of large databases can be challenging. Enter the subquery. This lesson will define a method for filtering results to a manageable level and provide working examples.

SQL: Inner Joins

3. SQL: Inner Joins

It is the most commonly-used way to merge data together in SQL. The Inner Join is used to select data from one or more tables for viewing or analysis. This lesson will describe the concept and provide syntax examples.

SQL: Left & Right Joins

4. SQL: Left & Right Joins

Left and right joins in SQL can be used to combine data from at least two tables found within a relational database. SQL is the database language that indicates how left and right joins are to be executed. In this lesson, you'll learn how to carry out left and right joins with SQL.

SQL: Full Outer Joins

5. SQL: Full Outer Joins

The full outer join, or the full join, is the SQL syntax used to combine all the rows from two or more tables. With the full outer join, no rows will be left out of the resulting table from the query. This lesson provides examples and explanations for using a full outer join.

SQL: Cross Joins

6. SQL: Cross Joins

Cross joins are the SQL equivalent of a multiplication operation: they join tables together in such a way that all of the records are returned from each table. Learn more about them in this lesson.

SQL: Self-Joins

7. SQL: Self-Joins

Joining a table to itself might sound contradictory. However, it is a useful and powerful tool in the SQL toolbox. We will cover the concept and provide examples of the power of a self-join.



When you have to compare data from different tables, you have three choices. You can make a new table, or you can use either UNION or JOIN. This lesson shows you which of those two to use.


9. SQL: GROUP BY Clause

When we go online shopping, we might have a favorite color for clothing, and perhaps we'd like to arrange them by color. The group by statement performs this function in SQL. In this lesson, we'll learn what the statement is and how it is used.



SQL is an important tool for manipulating information in today's world. In this lesson, we'll take a look at SQL, and two especially useful commands from the language, PIVOT and UNPIVOT.

What is a Cursor in SQL? - Example & Syntax

11. What is a Cursor in SQL? - Example & Syntax

Being able to locate and manipulate specific pieces of information is important today. In this lesson, we'll take a look at SQL, cursors in SQL, an example, and the syntax associated with a cursor.

What is SQL Injection? - Example & Prevention

12. What is SQL Injection? - Example & Prevention

In this lesson we will learn about SQL injection and how it is used by hackers to retrieve secure data. We will also discuss real life example and how SQL injection can be prevented.

SQL: Parameterized Queries

13. SQL: Parameterized Queries

SQL is a powerful tool for looking at information contained in a database. In this lesson, we'll take a look at SQL, what it is, what a query is, and what it means to parameterize a query.

Chapter Practice Exam
Test your knowledge of this chapter with a 30 question practice chapter exam.
Not Taken
Practice Final Exam
Test your knowledge of the entire course with a 50 question practice final exam.
Not Taken

Earning College Credit

Did you know… We have over 220 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Other Chapters

Other chapters within the SQL Tutorial & Training course