SQL JOIN with FROM/WHERE.
Joining tables with SQL FROM/WHERE.
-
A skeleton version of FROM/WHERE join syntax is this:
SELECT select_list FROM table_1, table_2 [, table_3]... WHERE [table_1.]column join_operator [table_2.]column [AND search_conditions ] [ORDER BY column1, column2, ... ]
Example:SQL server, MySQL, Oracle, PostgreSQL :select First_name "First name", Last_name "Last name", email, Telephone_type "Phone type", Telephone_number as "Phone number" from customers c, telephones t where c.customer_id=t.customer_id and Telephone_type<>'Unknown' order by Last_name;
- This is a SELECT where we joins Customers table with the Telephones table using the Customer_id column, which exists in both tables, to connect the tables.
-
We lists the name, email, telephone type and the phone number for
those that have known telephone_types.
The result should be:
First name Last name email Phone type Phone number Judith Bowman J.Bowman@imb.com Cell (371) 153-54 Judith Bowman J.Bowman@imb.com Work (371) 143-54 Ricard Nixon Ricard.Nixon@hotmail.com Work (978) 667-94 Ricard Nixon Ricard.Nixon@hotmail.com Home (978) 667-94 Robert Redford R.Redford@google.com Home (679) 234-94
© 2010 by Finnesand Data.
All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the
correctness in the pages or source codes.
The risk of using this web-site pages or any program
codes from this website is entirely at the individual user.