Home » SQL & PL/SQL » SQL & PL/SQL » join query between two same table structure
join query between two same table structure [message #233970] Sat, 28 April 2007 10:46 Go to next message
rajuakula
Messages: 63
Registered: March 2005
Member
hi,

I have two tables with same structure as below

table1

id no req fname lname
----------------------------------------
1 10 0 abc xyz
2 10 0 pqr mnc
3 10 0 efg trs


table 2

id no req fname lname
----------------------------------------
4 10 0 mno pts
5 10 1 tck mnq
6 11 0 ijk mtp

my output should be from both the tables
(join fields are no,req)

I need to pull the data from both the tables joining table1.no= table2.no and table1.req = table2.req and no=10 and req=0 .


id fname lname
-------------------
1 abc xyz
2 pqr mnc
3 efg trs
4 mno pts


thanks,
Re: join query between two same table structure [message #233975 is a reply to message #233970] Sat, 28 April 2007 12:02 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You have a clear requirement, just write it.
What is your problem?

Regards
Michel
Re: join query between two same table structure [message #233976 is a reply to message #233970] Sat, 28 April 2007 12:18 Go to previous messageGo to next message
rajuakula
Messages: 63
Registered: March 2005
Member
Can anybody plz. observe both the tables carefully.
table1 and table2 has same structure but the data differs.
I mentioned the data in both the tables
and I also mentioned the way my data should be displayed.


thanks
Re: join query between two same table structure [message #233977 is a reply to message #233976] Sat, 28 April 2007 12:20 Go to previous messageGo to next message
Michel Cadot
Messages: 64153
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
But you didn't mention what you already tried and what is blocking you.

Regards
Michel
Re: join query between two same table structure [message #233986 is a reply to message #233970] Sat, 28 April 2007 13:40 Go to previous message
flyboy
Messages: 1832
Registered: November 2006
Senior Member
Hi,
in fact your requirement does not lead to any kind of JOIN as you do not want to use values from both tables in one row.
You should use UNION ALL instead.
Previous Topic: Unique vs PK
Next Topic: Help with Select statement..
Goto Forum:
  


Current Time: Sun Dec 11 00:48:21 CST 2016

Total time taken to generate the page: 0.08092 seconds