Home » SQL & PL/SQL » SQL & PL/SQL » Which SQL statement is correct?
Which SQL statement is correct? [message #20415] Wed, 22 May 2002 01:42 Go to next message
karunamoorthy_p
Messages: 13
Registered: April 2002
Junior Member
Question:
Find all customers who have an Account and loan at CHENNAI branch.
Answer 1:
select customer_name from account_holders
where customer_name in (
select customer_name from loan
where branch_name = 'CHENNAI');

Answer 2:
select customer_name from account_holders
where branch_name = 'CHENNAI'
and customer_name in (
select customer_name from loan);

Plese tell me which answer is correct.
Re: Which SQL statement is correct? [message #20416 is a reply to message #20415] Wed, 22 May 2002 02:21 Go to previous messageGo to next message
M.P.KIRAN KUMAR
Messages: 9
Registered: May 2002
Junior Member
answer 1 is correct
Re: Which SQL statement is correct? [message #20418 is a reply to message #20415] Wed, 22 May 2002 11:57 Go to previous messageGo to next message
Sanjay Bajracharya
Messages: 279
Registered: October 2001
Location: Florida
Senior Member
No 3 from the post from 'm' will be the most efficient. Though 1 & 2 will also work.
Re: Which SQL statement is correct? [message #20519 is a reply to message #20415] Fri, 31 May 2002 09:12 Go to previous messageGo to next message
dug
Messages: 7
Registered: March 2002
Junior Member
select customer_name,loan from account_holders where branch_name ='CHENNAI' group by customer_name,loan

good to go
Re: Which SQL statement is correct? [message #20525 is a reply to message #20415] Fri, 31 May 2002 12:05 Go to previous message
dug
Messages: 7
Registered: March 2002
Junior Member
select a.customer_name,b.loan from account_holders a,loan b where b.branch_name ='CHENNAI' and a.customer_name = b.customer_name
Previous Topic: question
Next Topic: setting default values.
Goto Forum:
  


Current Time: Tue May 21 02:22:47 CDT 2024