using clause | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

using clause

can someone explain to me about the using clause to join tables? i mean, when and why you use using clause?

12th Nov 2016, 9:56 AM
Himas Adin Nugroho
Himas Adin Nugroho - avatar
2 Answers
+ 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'.
15th Nov 2016, 11:58 PM
Satyendra Chaudhary
Satyendra Chaudhary - avatar
0
wow that's so helpful ^^ thanks for your answer ^^
16th Nov 2016, 10:00 AM
Himas Adin Nugroho
Himas Adin Nugroho - avatar