Advanced sql tutorial

In Advanced Sql Tutorial, we are going to discuss the use of join, subquery or union query.

There are often times you are required to get complicated information that simple sql cannot accommodate.

This involves for example the task of joining two or more tables together to get data or appending results of two queries together.

With these techniques, we can use them for making exclusion or inclusion list, finding duplicate entries or create a data rank. Some examples are discussed in Problems and Solutions page.

Sql Join
You use Sql Join to retrieve data from more than one table in just one Select statement. Each "join" connects two tables, and you need to define the relationship. To do this you use one or more columns from each table and link them using comparison operators.

Three types of join:

  • Sql Inner Join
    You use the inner join to combine two tables based upon equal value of a connecting column.
  • Sql Outer Join
    There are two types, Left Outer Join and Right Outer Join. You use the Left Outer Join to combine two tables using a connecting column and return everything from Left table but only return those that match from the Right table. Left or Right Outer Join are basically similar, it depends on which way you see it. We can always change Right Outer Join with Left Outer Join by switching the tables' position.
  • Sql Self Join
    As the name suggested, this is joining a table to itself.

Sql Subquery
So, what is a subquery? It's an Sql Select that nests inside the WHERE clause of another Sql Select statement. A subquery itself is a full Sql statement in its own, and it needs to be enclosed by open and close parentheses and also referred to as inner subquery, while the next level up of a subquery is the outer level.

Sql Join and Sql Subquery can often be used interchangeably, it's the matter of preference. Although in some cases subquery is the only way to solve a problem.

Sql Union
Merging two or more queries into one result. Rows are appended from one queries to the other. The columns order must be the same and the columns types must be compatible. The UNION operation is different from using joins that combine columns from two tables.

Some implementations of these advanced sql are as follow, among others:

  1. Finding duplicate records
  2. Getting exclusion or inclusion list
  3. Almost similar to no 2, checking if a subset of a table
What we discuss in this advanced sql tutorial will be implemented in the Problems and Solutions page.

Buy at
A bend in the road is not the end of the road... unless you fail to make the turn

Positive Resources

All of us have at least two or three things that excite us. We could talk about these subjects for hours. Good news!. Did you know that Site Built It! can turn this type of deep interest and enthusiasm into a revenue-generating business?

Review some of the Site Build It! case studies and you'll absolutely discover something that ignites more positive ideas into your mind.

SBI! Video Tour

Invest the most
important 30 minutes
you will spend online.

Click, sit back, and
understand why SBI!
makes you succeed.