Reputation: 13
I'm new in the SQL/Oracle universe and I would like to ask for your help. This is a very simple question that I'm stuck in.
So, let me give you a picture. I have a regular table, let's call it "table1". The PK is the first column, "c1". Let's suppose that I would like to make the following select
:
select (1) from table1 where c1 in ('1','2','3')
This will give me
(1) | |
---|---|
1 | 1 |
2 | 1 |
3 | 1 |
However, if I make the following select
select (1) from table1 where c1 in ('1','2','2')
this will give me
(1) | |
---|---|
1 | 1 |
2 | 1 |
My question is, why in the second case there is not 3 records? Can I modify the second case to give 3 records, in other words, how can I prevent to the selection acts like a "distinct" clause?
I know that it may be a dummy question, so let me thank you all in advance.
Upvotes: 1
Views: 34
Reputation: 1269873
The where
clause filters rows generated by the from
clause.
Conditions in the where
clause only specify whether or not a given row is in the result set. They do not specify how many times a given row is in the result set.
If you want to "multiply" the number of rows, you would need to use a join
with a derived table that has duplicate values.
Upvotes: 1