May 3, 2008

Joining two tables in a single query

Two tables can be joined together in a query in four ways:

  • Inner Join: Returns only rows from both tables that satisfy the join condition.
  • Left Outer Join: Returns rows from both tables that satisfy the join condition, and the rest of rows from the first (left) table.
  • Right Outer Join: Returns rows from both tables that satisfy the join condition, and the rest of rows from the second (right) table.
  • Full Outer Join: Returns rows from both tables that satisfy the join condition, the rest of rows from both tables.
for example:-

SELECT
users.UserId ,users.FirstName ,users.MiddleName ,users.LastName
FROM Users inner join Properties
on users.userid= Properties.userid

you can use outer join,
right outer join or full outer join in place of inner join. There is no term like left inner join or right inner join.

No comments:

Search Here...

Popular Posts

Quick Test Professional