Query regarding Intersect clause

From: Ajit Pradnyavant <ajit(dot)pradnyavant(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Query regarding Intersect clause
Date: 2012-05-16 06:57:05
Message-ID: CAFu=Yd_UmEn0WXZZkwgsj6hyp5mq452xX-uDqGvg7yAeq0OvKg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sir,

I have created the following tables,

Create table abc (srno int, name varchar(32))
Create table def (srno int, name varchar(32))

abc
srno name
1 Aaaa
2 Bbbb

def
srno name
1 Aaaa
2 Cccc

each having two tuples.

If I run the following query I get the following result.
(Select name from abc) intersect (select name from def)

Srno Name
1 Aaaa

If I run the following query I get the following result.
(Select name from abc) intersect all (select name from def)

Srno Name
1 Aaaa

I think result of INTERSECT ALL query may be :

Srno Name
1 Aaaa
1 Aaaa

Because intersect all clause returns the duplicate values.
Please tell me I am wrong or correct.

Thank you in anticipation.

--
Sincerely,
Ajit Pradnyavant.
Email:- ajit(dot)pradnyavant(at)gmail(dot)com
Phone No. 7385758326

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Chris Angelico 2012-05-16 07:41:42 Re: Reserve one row for every distinct value in a column
Previous Message seiliki 2012-05-16 06:53:21 Reserve one row for every distinct value in a column