Join with Using clause

In this lesson we are going to study about Join with Using clause in a database.

Join with Using clause:
  • Using clause is used to join the tables where the column in those tables shares a same name .
  • Join operation carried out in these two table according to the values in these two columns.
  • The columns listed the using clause cannot have any qualifier in the
    statement and it should not include the where clause .
     It means we can’t select the value of these two columns in output and we
can’t use these columns in where clause.

Example:
we are having two table DEPARTMENTS and EMPLOYEES with comman column department_id .So, we can join this two table with Using clause.




SQL:

select e.employee_id,e.last_name,d.location_id
from employees e join departments d
using (department_id)



OUTPUT:

 same result with equi join:

select  e.employee_id,
e.last_name,d.location_id
from employees e , departments d
where e.employee_id =d.department_id







NOTE:
  • Do not use a table name or alias in referenced columns.
  • The NATURAL JOIN and USING clause are mutually exclusive.

Related Article
I am interested in hearing your feedback, so that I can improve my articles and learning resources for you.connect with us on facebooktwitter

Share

Did you enjoy reading this and found it useful? If so, please share it with your friends:

No comments:

Post a Comment