sql course



when joining multiple table it may be beneficial to use a standard layout for the query.



	select 
		a.customer_id,
		b.date_joined,
		c.address1,
		d.account_id
	from
		customer_details a
	inner join
		cust_details b
	on
		b.customer_id = a.customer_id
	left join
		cust_address c
	on
		c.customer_id = a.customer_id
	left join
		cust_accounts d
	on
		d.customer_id = a.customer_id
	;
	
	
continue down the page joining in whichever tables are necessary for the format required.

it's only possible to refer to fields that are earlier in the query when joining tables.

the 'where', 'group by' etc. statements follow the last line of joined tables.
