0
using clause
can someone explain to me about the using clause to join tables? i mean, when and why you use using clause?
2 Réponses
+ 1
'USING' clause can only used when both tables have a identical common column. Where as 'ON' can be used on any field, dis-regarding it's name or type.
Example:
SELECT * from employee_profiles LEFT JOIN employee_work_descriptions USING (employee_code);
Here both table(employee_profiles and employee_work_descriptions) have a common field named 'employee_code'.
SELECT * from employees LEFT JOIN employee_profiles ON (employee_profiles.employee_ecode = employee.code);
Here 'employees' table has a column(also primary key) named 'code' which is matched with 'employee_ecode' column(also foreign key) of the table 'employee_profiles'.
0
wow that's so helpful ^^ thanks for your answer ^^