Amazon Interview Question






Comment hidden because of low score. Click to expand.
3
of 3 vote

You can sort of do a union with a full outer join. It works as long as none of the values that you're joining overlap in each table. Try this:

SQL> create table table1 (name varchar2(100), id varchar2(100));

Table created.

SQL> create table table2 (name varchar2(100), id varchar2(100));

Table created.

SQL> insert into table1 (name, id) values ('table1 name', 'table1 id');

1 row created.

SQL> insert into table2 (name, id) values ('table2 name', 'table2 id');

1 row created.

SQL> select * FROM table1 full outer join table2 using (name, id);

NAME										     ID
--------------------------------------------------------------------------------------
table2 name									     table2 id
table1 name									     table1 id

Also, if you don't care about having the data in the same column you can do this:

SQL> select * FROM table1 t1 full outer join table2 t2 on 1 = 2

- chris March 01, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Using SQL queries that require 'OR' condition can be done either using JOIN or UNION

- KM July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I don't think its possible because Join increases the number of column
while UNION increases the number of rows

- Anonymous July 06, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

I agree with previous comment. Otherwise, one would need more clarification from interviewer to know exactly what he intends to say since, this look pretty trivial.

- Asheesh July 07, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The question is just a trap.
Join is a projection,union is a selection.
Join is used to perform a relation between 2 or more tables( or 2 instances of the same table), where as UNION just adds two result sets..

- nag August 21, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

FULL OUTER JOIN is a UNION of LEFT JOIN and RIGHT JOIN

- nandlogics March 28, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

UNION and JOINS are both different concepts. Indeed you can do this to achieve the same results but both are different in terms of executions and plan creation.
JOIN affect the SELECTIVITY while UNION is considered while PROJECTING the data.

- SIM April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

UNION and JOINS are both different concepts. Indeed you can do this to achieve the same results but both are different in terms of executions and plan creation.
JOIN affect the SELECTIVITY while UNION is considered while PROJECTING the data.

- SIM April 21, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

It is based on use case. It can be done.

- Anonymous February 03, 2013 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More