If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Oracle > Question about SubSelects

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-07-11, 23:08
noodlesup noodlesup is offline
Registered User
 
Join Date: Dec 2011
Posts: 3
Question about SubSelects

Hi all,

I happen to have an oracle quiz to answer at school and I completed it except this one very question:

Quote:
If used in a WHERE clause, what is the maximum number of rows that can be returned by a SUB SELECT? Why?
I just don't know what to answer. I'd say there is no maximum, but I can't find anything confirming that anywhere, and I have no idea how to answer the "why".

Your thoughts would be much appreciated!
Reply With Quote
  #2 (permalink)  
Old 12-07-11, 23:44
anacedent anacedent is offline
Registered User
 
Join Date: Aug 2003
Location: Where the Surf Meets the Turf @Del Mar, CA
Posts: 6,416
Rhetorical question -
can sub-select return more rows than exist within complete result set?
Please justify your response.
__________________
You can lead some folks to knowledge, but you can not make them think.
The average person thinks he's above average!
For most folks, they don't know, what they don't know.
Reply With Quote
  #3 (permalink)  
Old 12-08-11, 03:19
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
Depends on the WHERE condition. Look at this:
SELECT some_fields
FROM some_table
WHERE a_field = (sub_SELECT)

Then look at ORA-01427
__________________
Florin Aparaschivei
Iasi, Romania
Reply With Quote
  #4 (permalink)  
Old 12-08-11, 03:52
Littlefoot Littlefoot is offline
Lost Boy
 
Join Date: Jan 2004
Location: Croatia, Europe
Posts: 3,629
Heh, are you saying that a subquery can return too many rows?
Reply With Quote
  #5 (permalink)  
Old 12-08-11, 04:46
noodlesup noodlesup is offline
Registered User
 
Join Date: Dec 2011
Posts: 3
Red face

Quote:
Originally Posted by aflorin27 View Post
Depends on the WHERE condition. Look at this:
SELECT some_fields
FROM some_table
WHERE a_field = (sub_SELECT)

Then look at ORA-01427
Yeah I understand it's because of the "=" which means we're only allowed one row in this case.

But what if it was WHERE a_field in (sub_SELECT) ?

I mean, the sub select can return a full table so how do I know what is the maximum number of rows returned without any clue on the WHERE clause?

That's why I'm confused by this question :/
Reply With Quote
  #6 (permalink)  
Old 12-08-11, 07:54
aflorin27 aflorin27 is offline
Registered User
 
Join Date: Apr 2008
Location: Iasi, Romania
Posts: 317
So you got the answer: it depends on the condition.
__________________
Florin Aparaschivei
Iasi, Romania
Reply With Quote
  #7 (permalink)  
Old 12-17-11, 23:41
noodlesup noodlesup is offline
Registered User
 
Join Date: Dec 2011
Posts: 3
I got all the points on this question thx guys
Reply With Quote
Reply

Tags
oracle subselect

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On