Is it possible to perform a dynamic SQL join?

Why NATURAL JOIN and JOIN...USING produce different results in SQL?

  • Why doesn't the 2 queries below produce the same result? Query 1: select last_name, department_id, department_name from employees join departments using (department_id); Query 2: select last_name, department_id, department_name from employees natural join departments;

  • Answer:

    The first query joins the two based on department_id and only that column. The second will join the two based on every set of columns between the two with the exact same name.

Boolean at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

It depends on the number of columns with coinciding names in the both tables.

Serge M

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.