In this lesson we are going to study about Join with Using clause in a database.
Join with Using clause:
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.
select e.employee_id,e.last_name,d.location_id
from employees e join departments d
using (department_id)
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:
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 facebook, twitter
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 .
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 facebook, twitter
No comments:
Post a Comment