sql query to join two tables code example
Example 1: how to join tables in sql
JOINING 2 Tables in sql
SELECT X.Column_Name , Y.Column_Name2
FROM TABLES1_NAME X
INNER JOIN TABLES2_NAME Y ON X.Primary_key = Y.Foreign_key;
SELECT E.FIRST_NAME , J.JOB_TITLE
FROM EMPLOYEES E
INNER JOIN JOBS J ON J.JOB_ID = E.JOB_ID;
Example 2: sql server joins
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate
FROM Orders
INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;
Example 3: sql join two queries
SELECT t1.Activity, t1."Total Amount 2009", t2."Total Amount 2008"
FROM (query1) as t1, (query2) as t2
WHERE t1.Activity = t2.Activity