Question : Which join is performed by the following query? (Choose the best answer.) SELECT E.USER_ID, J.CLICK_ID FROM TABLE1 E and TABLE2 J ON (E.CLICKS < J.MAX_CLICKS); 1. Equijoin 2. Nonequijoin 3. Access Mostly Uused Products by 50000+ Subscribers 4. Outer join
Explanation: The join condition is an expression based on the less than inequality operator. Therefore, this join is a nonequijoin.
Question : Which of the following statements are syntactically correct? 1. SELECT * FROM EMPLOYEES E JOIN DEPARTMENTS D USING (DEPARTMENT_ID); 2. SELECT * FROM EMPLOYEES JOIN DEPARTMENTS D USING (D.DEPARTMENT_ID); 3. Access Mostly Uused Products by 50000+ Subscribers 4. None of the above
Correct Answer : Get Lastest Questions and Answer : Explanation: ou're presumably already aware of the distinction, but from the documentation: ON condition Use the ON clause to specify a join condition. Doing so lets you specify join conditions separate from any search or filter conditions in the WHERE clause. USING (column) When you are specifying an equijoin of columns that have the same name in both tables, the USING column clause indicates the columns to be used. You can use this clause only if the join columns in both tables have the same name. Within this clause, do not qualify the column name with a table name or table alias. So these would be equivalent:
select e.ename, d.dname from emp e join dept d using (deptno);
select e.ename, d.dname from emp e join dept d on d.deptno = e.deptno; To a large extent which you use is a matter of style, but there are (at least) two situations where you can't use using: (a) when the column names are not the same in the two tables, and (b) when you want to use the joining column:
select e.ename, d.dname, d.deptno from emp e join dept d using(deptno);
select e.ename, d.dname, d.deptno * ERROR at line 1: ORA-25154: column part of USING clause cannot have qualifier You can of course just leave off the qualifier and select ..., deptno, as long as you don't have another table with the same column that isn't joined using it:
select e.ename, d.dname, deptno from emp e join dept d using (deptno) join mytab m using (empno);
select e.ename, d.dname, deptno * ERROR at line 1: ORA-00918: column ambiguously defined
Question : The EMPLOYEES and DEPARTMENTS tables have two identically named columns: DEPARTMENT_ID and MANAGER_ID. Which of these statements joins these tables based only on common DEPARTMENT_ID values? 1. SELECT * FROM EMPLOYEES NATURAL JOIN DEPARTMENTS; 2. SELECT * FROM EMPLOYEES E NATURAL JOIN DEPARTMENTS D ON E.DEPARTMENT_ID=D.DEPARTMENT_ID; 3. Access Mostly Uused Products by 50000+ Subscribers 4. None of the above
Correct Answer : Get Lastest Questions and Answer : Explanation: . The queries in 2 and 3 incorrectly contain the NATURAL keyword. If this is removed, they will join the DEPARTMENTS and EMPLOYEES tables based on the DEPARTMENT_ID column.
1. SELECT columns FROM table1 LEFT [OUTER] JOIN table2 ON table1.column = table2.column; 2. SELECT columns FROM table1 INNER JOIN table2 ON table1.column = table2.column; 3. Access Mostly Uused Products by 50000+ Subscribers FROM table1 RIGHT [OUTER] JOIN table2 ON table1.column = table2.column; 4. SELECT columns FROM table1 FULL [OUTER] JOIN table2 ON table1.column = table2.column;
1. SELECT columns FROM table1 LEFT [OUTER] JOIN table2 ON table1.column = table2.column; 2. SELECT columns FROM table1 INNER JOIN table2 ON table1.column = table2.column; 3. Access Mostly Uused Products by 50000+ Subscribers FROM table1 RIGHT [OUTER] JOIN table2 ON table1.column = table2.column; 4. SELECT columns FROM table1 FULL [OUTER] JOIN table2 ON table1.column = table2.column;