Thread: SQL joio query
View Single Post
 
Old August 4th, 2010, 02:06 PM
tusharkale tusharkale is offline
Authorized User
 
Join Date: Aug 2006
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to tusharkale
Default SQL joio query

Hello,

I have two select statements as

Query 1 : Select col1,col2,col3,col4,value_a from table_1

Query 2: Select col1,col2,col3,col4,value_b from table_2

I want to join these two select statement to get below result.

col1 col2 col3 col4 value_a value_b


Scenario 1: Both query fecth the result

Result of query 1:

Col1 Col 2 Col3 Col4 Value_a
1 TK TL TM 100

Result of query 1:

Col1 Col 2 Col3 Col4 Value_b
1 TK TL TM 200

Ultimate join result should be
Col1 Col 2 Col3 Col4 Value_a value_b
1 TK TL TM 100 200


Scenario 2: Only one query fetches the result


Result of query 1:

Col1 Col 2 Col3 Col4 Value_a
1 TN TO TP 300

Result of query 1:

Col1 Col 2 Col3 Col4 Value_b

Ultimate join result should be
Col1 Col 2 Col3 Col4 Value_a value_b
1 TN TO TP 300 0

How should I join these?