Blog Archive for October 1, 2012

Join to a Query

October 1, 2012

Using the new SQL join syntax, you can join to a query rather than a table:

select * from album
inner join (select * from track where trk_name = 'Money') x on trk_album = abm_serial;

It's important to alias the subquery that you're joining on, otherwise you'll …

3 Table SQL Joins

October 1, 2012

Following on from http://drumcoder.co.uk/blog/2012/oct/01/sql-joins/, I wanted to do the same process with three tables.

Our artist and album tables now look like this:

 abm_serial |       abm_name        | abm_artist 
------------+-----------------------+------------
          1 | Dark Side of the Moon |          1
          6 | Brave                 |          2
          2 | A Night at the …

SQL Joins

October 1, 2012

I've always struggled understanding the difference between the different types of join available in SQL. It does, however, make much more sense now I've looked at the new style join syntax.

Table Structure

Given the following tables:

 abm_serial |       abm_name        
------------+-----------------------
          1 | Dark Side of the Moon
          2 | …