Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

SQL Question

This is a discussion on SQL Question within the SQL forums, part of the Databases category; We have two tables: create table emp ( emp_id int, emp_name varchar(10) ) create table sal ( emp_id int, sal float ) Show all employees who did not receive their ...

Go Back   Geeks Talk > Databases > SQL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 07-14-2009
Junior Member
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
anders055 is on a distinguished road
SQL Question

We have two tables:
create table emp
(
emp_id int,
emp_name varchar(10)
)

create table sal
(
emp_id int,
sal float
)

Show all employees who did not receive their salary...in other words show those emp_names from the 'emp' table whose emp_id does not exist in the 'sal' table. Use joins only. Sub Query is not allowed.
Reply With Quote
The Following 2 Users Say Thank You to anders055 For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 07-14-2009
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,860
Thanks: 9
Thanked 168 Times in 142 Posts
debasisdas has a spectacular aura aboutdebasisdas has a spectacular aura about
Re: SQL Question

do your home work your self .

kindly post what you have tried sofar
Reply With Quote
  #3 (permalink)  
Old 07-14-2009
Contributing Member
 
Join Date: Apr 2008
Location: Gurgaon
Posts: 43
Thanks: 1
Thanked 3 Times in 3 Posts
sarikagupta is on a distinguished road
Re: SQL Question

please clear which database u r using and why you want the same using join as usnig NOT IN and subquery you can execute the query with better efficiently.
Reply With Quote
  #4 (permalink)  
Old 07-14-2009
Junior Member
 
Join Date: Jul 2008
Posts: 2
Thanks: 0
Thanked 2 Times in 1 Post
anders055 is on a distinguished road
Re: SQL Question

debasisdas --this not my homework...just an interview question i am trying to solve. This was asked in my last inteview.

sarikagupta -- use any database. These tables are an example. Using subquery would not be more efficient as you would have to select all rows of the sal table in the subquery.

select emp_name from emp where emp_id not in (select emp_id from sal)

Need to do this using only joins.
Reply With Quote
  #5 (permalink)  
Old 07-15-2009
Moderator
 
Join Date: Jun 2007
Location: Bangalore,India
Posts: 1,860
Thanks: 9
Thanked 168 Times in 142 Posts
debasisdas has a spectacular aura aboutdebasisdas has a spectacular aura about
Re: SQL Question

Sub query is the best solution to avoid anti-join.
Reply With Quote
Reply

  Geeks Talk > Databases > SQL

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Question about QTP SangeethaG QTP 4 09-12-2008 02:27 AM
Question Manoj.Oracle Oracle Apps 2 03-10-2008 08:54 AM
Question padmakrishna Java 0 01-22-2008 04:04 PM
SAS Question abdul99 Data Warehousing 0 07-19-2007 05:28 PM
QTP question? hetal desai QTP 3 07-11-2007 03:31 PM


All times are GMT -4. The time now is 12:34 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved