SQL Left Outer Join - 1keyd..

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

SQL Left Outer Join - 1Keydata SQL Tutorial

http://www.1keydata.com/sql/left-outer-join.html

SQL Left Outer Join


SQL Tutorial SQL Commands Table Manipulation String Functions Date Functions Advanced SQL SQL Syntax

SQL SELECT SQL DISTINCT SQL WHERE SQL AND OR SQL IN SQL BETWEEN SQL Wildcard SQL LIKE SQL ORDER BY SQL Functions SQL Average SQL COUNT SQL MAX SQL MIN SQL SUM SQL GROUP BY SQL HAVING SQL ALIAS SQL AS SQL JOIN SQL INNER JOIN SQL OUTER JOIN SQL LEFT OUTER JOIN SQL CROSS JOIN SQL SELECT UNIQUE SQL ROUND SQL CAST SQL CONVERT SQL CONCATENATE SQL SUBSTRING SQL INSTR SQL TRIM SQL LENGTH SQL REPLACE SQL DATEADD SQL DATEDIFF SQL DATEPART SQL GETDATE SQL SYSDATE SQL CREATE TABLE SQL CONSTRAINT SQL NOT NULL SQL DEFAULT SQL UNIQUE SQL CHECK SQL PRIMARY KEY SQL FOREIGN KEY SQL View SQL CREATE VIEW SQL Index SQL CREATE INDEX SQL ALTER TABLE SQL DROP TABLE SQL TRUNCATE TABLE SQL USE SQL CREATE DATABASE SQL DROP DATABASE SQL INSERT INTO SQL UPDATE SQL DELETE FROM SQL Jobs Site Map

SQL > SQL Commands > Left Outer Join


Automated Assessments Full Analysis of your Datases and Apllications
www.ateras.com/

In an left outer join, all rows from the first table mentioned in the SQL query is selected, regardless whether there is a matching row on the second table mentioned in the SQL query. Let's assume that we have the following two tables, Table Store_Information
store_name Sales Date Los Angeles $1500 Jan-05-1999 San Diego Los Angeles Boston $250 Jan-07-1999 $300 Jan-08-1999 $700 Jan-08-1999

Graph Your SQL Data Turn your SQL database into sleek charts and business graphs.
chart.io

Table Geography
region_name store_name East East West West Boston New York Los Angeles San Diego

SQL Server 2008 Training Best Trainers, Best Place to Work in Indian Training Industry
www.Koenig-India.com

We want to find out sales by store, and we want to see the results for all stores regardless whether there is a sale in the Store_Information table. To do this, we can use the following SQL statement using LEFT OUTER JOIN: SELECT A1.store_name STORE, SUM(A2.Sales) SALES FROM Geography A1 LEFT OUTER JOIN Store_Information A2 ON A1.store_name = A2.store_name GROUP BY A1.store_name Result: STORE Los Angeles San Diego New York Boston SALES $1800 $250 NULL $700

New Free Software Download Buy Pen Drives, Music CD's, Mobiles Gifts, Apparels, Watches and more!
Shopping.Indiatimes.com

Qt Professional Training Qt Courses - beginner to advanced - given by active Qt Developers


www.kdab.com/training

By using LEFT OUTER JOIN, all four rows in the Geography table is listed. Since there is no match for "New York" in the Store_Information table, the Sales total for "New York" is NULL. Note that it is NULL and not 0, as NULL indicates there is no match. SQL Cross Join >> Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.

Version Database Objects


DBVS versions database objects and deploys SQL. Get it free now!
www.dbvsys.com

More 1Keydata Tutorials


Data Warehousing: Data Modeling Business Intelligence Data Integrity Star Schema Logical Data Model CSS Tutorial: CSS Background CSS Border CSS Padding CSS Overflow CSS Margin CSS Cursor PHP Tutorial: PHP Foreach PHP Redirect PHP Array PHP Include PHP Explode PHP For Loop PHP Substr

1 of 2

4/12/2012 8:52 PM

SQL Left Outer Join - 1Keydata SQL Tutorial

http://www.1keydata.com/sql/left-outer-join.html

HTML Tutorial: Radio Button HTML Checkbox HTML Drop Down Basic HTML Tags Text Input Color Codes

Resources

Copyright 2012 1keydata.com All Rights Reserved.

Privacy Policy

2 of 2

4/12/2012 8:52 PM

You might also like