SQL Tutorial: 1
SQL is short for Structured Query Language and is a widely used database language, providing means of data manipulation (store, retrieve, update, delete) and database creation.
If you need a quick SQL reference, make sure you download or PDF SQL Cheat Sheet.
Almost all modern Relational Database Management Systems like MS SQL Server, Microsoft Access, MSDE, Oracle, DB2, Sybase, MySQL, Postgres and Informix use SQL as standard database language. Now a word of warning here, although all those RDBMS use SQL, they use different SQL dialects. For example MS SQL Server specific version of the SQL is called T-SQL, Oracle version of SQL is called PL/SQL, MS Access version of SQL is called JET SQL, etc.
Our SQL tutorial will teach you how to use commonly used SQL commands and you will be able to apply most of the knowledge gathered from this SQL tutorial to any of the databases above.
SQL Tutorial Table of Contents
This chapter explains what SQL (Structured Query Language) is, and where and how it is used.
SQL Database Tables are the building blocks of every RDBMS (Relational Database Management System). Learn more about SQL tables here.
Learn how to use the SELECT SQL statement to retrieve data from one or more SQL database tables and/or database views.
SQL SELECT INTO
Learn how to use the SQL SELECT INTO statement to copy data between database tables.
Learn how to use the SQL DISTINCT clause together with the SQL SELECT keyword, to return a dataset with unique entries for certain database table column(s).
The SQL WHERE clause is used to specify selection criteria, thus restricting the result of a SQL query or SQL data manipulation statements like UPDATE and DELETE.
The SQL LIKE clause is used along with the SQL WHERE clause and specifies filtering criteria based on a string pattern.
SQL INSERT INTO
Learn how to use the SQL INSERT INTO clause to insert data into a SQL database table.
The SQL UPDATE statement is used to modify data in a SQL database table.
Learn how to use the SQL DELETE statement to delete remove records from a SQL database table.
SQL ORDER BY
Learn how to use the SQL ORDER BY clause to sort the data retrieved in your SQL query in ascending or descending order.
SQL OR & AND
Learn how to use the SQL OR & AND keywords together with the SQL WHERE clause to add several conditions to your SQL statement.
The SQL IN clause allows you to specify discrete values in your SQL WHERE search criteria.
The SQL BETWEEN & AND keywords define a range of data between 2 values.
SQL aliases can be used with database tables and/or with database table columns, depending on task you are performing.
The SQL COUNT aggregate function is used along with the SELECT keyword to count the number of rows returned from a SQL query.
The SQL MAX aggregate function allows us to select the highest (maximum) value for a certain column.
The SQL MIN aggregate function allows us to select the lowest (minimum) value for a certain column.
The SQL AVG aggregate function selects the average value for a certain table column.
The SQL SUM aggregate function allows selecting the total for a numeric column.
SQL GROUP BY
The SQL GROUP BY statement is used along with the SQL aggregate functions like SUM to provide means of grouping the result dataset by certain database table column(s).
The SQL HAVING clause is used to restrict conditionally the output of a SQL statement, by a SQL aggregate function used in your SELECT list of columns.
The SQL JOIN clause is used whenever we have to select data from 2 or more tables related by common columns.