Select from T1, T2
HelloCan someone help me how to explain this selection on these 2 tables, I'm stuck with line #3, marked with "xxx", it's just to JOIN them, not select columns but imported T2 in Select for further assessment predicate?
This is an example, where we need to filter only the records from the first table where all the sub_item_cd are in the second table, IE.
item_cd
1010
1012
But it's okay for that matter, just trying to digest the logic of this select. I see that even an output for lines1, 2, 3 produce some cortesian products that I can't explain.
All TX
T
select t1.item_cd ----- #1
from t1, ------#2
(select distinct sub_item_cd from t2 ) t2 --------#3/* xxx */
where t1.sub_item_cd = t2.sub_item_cd(+) --------#4
group by t1.item_cd --------#5
having max(decode( t2.sub_item_cd, NULL, 1, 0 )) = 0 ---------#6
T1::::
item_cd sub_item_cd
1010 A
1010 B
1010 C
1011 A
1011 D --/* D not in T2
1012 A
T2::::
sub_item_cd
A
A
A
B
B
C
B
C
Hello
Sorry, I can't tell what you're asking, if anything. The thread is not marked as 'Response', so I guess you still have questions.
Trento wrote:
TX, FrankRe Cartiesian: I meant that the result of this query (line 1-3) produced 18 rows of item_cd, there is even this column in t2,
A word or two to let out the sentence just before that?
When you say t2 here, are you talking about the table called t2 or view online called t2? (This is an example of why it is wrong to give the same name at the same time).
What are the columns in the view online t2 don't matter at all here, since these none of these columns are referenced in the SELECT clause or anywhere else in the main query. All that matters on line t2 is the number of lines is in it.
so it of confused me, just can't get what's behind
select t1.item_cd ----- #1 from t1, ------#2 (select distinct sub_item_cd from t2 ) t2 --------#3/* xxx */
If it was your entire query, then it would be a cross join, because you'd have two 'paintings' (actually, a table and a view online) and they are not bound by the join conditions. Each of the 6 T1 lines and would be joined at each of the 3 lines to view on line t2, for a total of 6 * 3 = 18 rows.
However, this isn't your entire query, and I'm not sure it helps to examine what happens when it comes to an entire query.
The rest is very clear now, tx at all
Tags: Database
Similar Questions
Maybe you are looking for
-
To find rest of park areas to maps
My neighborhood local park working with its nonprofit and a local healthcare provider collects an annual "trails challenge." The idea is that every year, they trace clues in various parks in the system and encourage participants to walk enough of the
-
If you buy a mini iPad 2 with only WiFi - can you add later cell?
If you buy a mini iPad 2 with only WiFi - can you add later cell?
-
Satellite S1900-303 needs new DVD/CD player
The DVD/CD on my Satellite S1900-303 drive needs to be replaced (not surprising given the age of the laptop!) It was purchased in January 2003 and is still going strong I would like to replace the old disk with a DVD R/W drive. Can anyone suggest a c
-
How to get the PC host name using labview
Hello I have a need to display the name of the host (login name) pc in my application. How do I get using labview in DURATION that is if I write a program and run it in different systems of PC / same system with different users, so I should get corre
-
Understand the values fixed point of a NOR-9203
I have a cRIO-9073 with a NI 9203 module. In LabVIEW FPGA, the card values are returned as a fixed point. LabVIEW chosen fixed point properties are (+/-, 21-4) that apparently offers a range of (- 3.125E - 2, 3.125E - 2, 2.98E - 8), and the current c