SQL Book

SQL at SQL Book

Introduction to SQL

The articles in this section are aimed at giving a quick but thorough introduction to SQL, what it is, how it can be used and an introduction to the main 'bread and butter' commands.

Introduction to SQL
SQL stands for Structured Query Language. Structured Query Language is a standard computer language that is used to communicate with databases.

Using the SQL SELECT Statement
In this multi part series on the SQL SELECT statement we will start off demonstrating the SELECT statement in its simplest form and then building on this we will demonstrate additional aspects of the SELECT statement.

The SQL WHERE Clause
In this article we will see how the WHERE clause can be used to select specific rows from the table that match certain specified criteria or conditions.

Using the SELECT INTO statement to create backup and archive copies of data
This article identifies common uses for the SELECT INTO statement and gives syntax definition and code examples to demonstrate the statements potential uses.

SQL UNION and UNION ALL
The SQL UNION command can be used to combine the output from 2 or more SELECT statements into 1 resultset. This article explains the syntax and rules of the UNION command and gives real world examples of it in use.

SQL LIKE - flexible string matching
The SQL LIKE operator is often used in the WHERE clause to find string matches on part of a column value by using a wildcard character. Article include examples, syntax and tips.

Using SQL DISTINCT
Find out how to use the SQL DISTINCT command to return only unique rows. Article includes the syntax and real world example of it in use.

SQL Inner Join - examples and explanations
The SQL Inner Join statement enables us to retrieve data from two or more related tables in one SQL query.

The SQL Outer Join - return all specified rows from one of the two tables in the join
The SQL Outer Join can be used to define a relationship between columns in two different tables and will return all rows from one of the tables whether a related record in the other table exists or not.


SQL String Functions

The articles in this section demonstrate the various functions that can be used manipulate strings in SQL.

SQL String Functions
SQL provides us with a number of tools that give us the ability to manipulate string values. This section of the site gives details of the various functions available and demonstrates real world examples of their use.

SQL CONCATENATE (appending strings to one another)
SQL allows us to concatenate strings but the syntax varies according to which database system you are using. Concatenation can be used to join strings from different sources...

SQL Coalesce function - how to use it with examples
The SQL Coalesce function returns the value of the first of its input parameters that is not NULL. Although it can be used with strings, COALESCE it is not limited to being passed just strings.

SQL TRIM Functions, purpose, syntax and common uses
This article demonstrates how to remove white spaces from the beginning and end of string variables using SQL TRIM / LTRIM / RTRIM functions.

SQL Replace Function, purpose, syntax and common uses
The article explains the functionality, syntax and common uses of the SQL Replace function. The SQL Replace function enables us to look for a certain character phrase in a string and replace it with another character phrase.

SQL Substring Function
The SQL Substring function enables us to extract a section of a string. The syntax of this function (and even its name) varies depending on which database you are using.


Securing your SQL applications

A hackers prime target is often a database of some kind and they can use SQL commands and other security vunerabilities to gain access to your database. Learn how to secure your databases in these articles.

SQL Injection Attacks - are your databases secured?
In this 2 part series we will demonstrate what SQL injection is, how the hacker can use it against you and how you can protect yourself by employing a number of different strategies in your database and the design of your front end applications.

Defending against SQL Injection attacks
In this article we will look at the methods you can secure your database and front end applications to protect yourself from SQL Injection hacks.


Advanced SQL Querying

The articles in this section demonstrate some more advanced techniques that can be used to query your database.

Creating Dynamic SQL statements that reflect user form selections
A frequent business requirement is the implementation of a form that allows a user to filter data. This can require the developer to create dynamic SQL statements that reflect the filters specified by the user

Creating a comma delimited list of column values without a SQL cursor
There may be many reasons you want to build a comma delimited list of values from a table column. This article demonstrates how to build this list without using a cursor.

Using SQL Cross Join - the report writers secret weapon
The SQL CROSS JOIN is an often overlooked part of SQL but it can prove invaluable if you are aware of which situations it can be useful in.

SQL Cursors - how to avoid them
Whilst many SQL books advise you not to use SQL cursors, not many provide alternative solutions. This article shows how alternatives to cursors can be implemented.

Using SQL to parse a comma delimited list - example code
This example SQL script shows how to parse a comma delimited list using SQL




Tell a friend about this page