|
Re: Join diffrent tables [message #293278 is a reply to message #293269] |
Fri, 11 January 2008 09:29   |
 |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
Use UNION ALL just add NULL in SELECT for the rows that contain less columns.
Next time, instead of an image, please read and follow OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Use the "Preview Message" button.
Also post your Oracle version (4 decimals) and a test case: create table and insert statements.
Regards
Michel
[Updated on: Fri, 11 January 2008 09:29] Report message to a moderator
|
|
|
|
Re: Join diffrent tables [message #293522 is a reply to message #293269] |
Sun, 13 January 2008 22:07   |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
SQL> select * from test1;
A B
---------- ----------
1 2
3 4
5 6
SQL> select * from test2;
A B C
---------- ---------- ----------
11 22 33
44 55 66
77 88 99
SQL> select a,b,decode(c,0,'null',c) as c
2 from (select a,b,0 as c from test1
3 union
4 select a,b,c from test2);
A B C
---------- ---------- --------------------------------------
1 2 null
3 4 null
5 6 null
11 22 33
44 55 66
77 88 99
6 rows selected.
|
|
|
|
Re: Join diffrent tables [message #293567 is a reply to message #293269] |
Mon, 14 January 2008 02:14   |
mshrkshl
Messages: 247 Registered: September 2006 Location: New Delhi
|
Senior Member |
|
|
not too much difference.
SQL> ed
Wrote file afiedt.buf
1 select a,b,decode(c,null,'null',c) c
2 from (select a,b,null as c from test1
3 union
4* select a,b,c from test2)
SQL> /
A B C
---------- ---------- ----------------------------------------
1 2 null
3 4 null
5 6 null
11 22 33
44 55 66
77 88 99
6 rows selected.
|
|
|
Re: Join diffrent tables [message #293570 is a reply to message #293567] |
Mon, 14 January 2008 02:29  |
 |
Michel Cadot
Messages: 68733 Registered: March 2007 Location: Saint-Maur, France, https...
|
Senior Member Account Moderator |
|
|
You miss my point.
The result should be NULL and NOT the string "null".
Even if it was the string "null" there is no use of an outer query.
Regards
Michel
|
|
|