on 03-02-2010 11:17 AM
This statement should return one row, but i get no result:
select *
from dual t1
left join dual t2
on t2.dummy = 'b'
But this statement works:
select *
from dual t1
left join dual t2
on t2.dummy != t1.dummy
Why?
Best Regards,
Stephan
Hi,
in MaxDB version <= 7.7 we have a problem at outer joins without real join transition.
We will fix this bug with one of our next patches.
You could check the proceeding with this link
http://sapdb.org/webpts?wptsdetail=yes&ErrorType=0&ErrorID=1216351
Thank you for reporting this bug.
Kind regards
Holger
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> This statement should return one row, but i get no result:
>
>
select *
> from dual t1
> left join dual t2
> on t2.dummy = 'b'
No - this statement should not deliver one row.
DUAL contains just one row with one column value 'a'.
There's no way this query can produce anything but the empty result set!
Make it "on t2.dummy ='a'" and you'll get your row!
> But this statement works:
>
select *
> from dual t1
> left join dual t2
> on t2.dummy != t1.dummy
>
> Why?
Because "LEFT JOIN" is short for "LEFT OUTER JOIN".
For the database this means: take all matching rows from table t1 and try to match them with the join condition.
If you find matches, include them into the result set, if not, include a NULL value instead.
And that is what happens.
By the way: precisely this case is described in the documentation of MaxDB as well (MaxDB Documentation > Reference > SQL Reference Manual > Frequently Used Syntax Elements: Overview > Joined Table (joined_table) )...
regards,
Lars
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
select *
from dual t1
left join dual t2
on t2.dummy = 'b'
This is exactly what i mean.
I select one row from t1 and use a LEFT OUTER JOIN to join t2.
t2 joins no result to t1.
Therefore t1.dummy should be 'a' and t2.dummy should be NULL
select *
from dual t1
left join dual t2
on t2.dummy != t1.dummy
This statement should return the same result like the first statement. One row from t1 and LEFT JOIN no row from t2. And it works. But if this works (i think it's the correct behaviour), why the first statement return nothing? The principle is the same.
>
>
select *
> from dual t1
> left join dual t2
> on t2.dummy = 'b'
>
> This is exactly what i mean.
> I select one row from t1 and use a LEFT OUTER JOIN to join t2.
> t2 joins no result to t1.
> Therefore t1.dummy should be 'a' and t2.dummy should be NULL
You're right - this is not working correctly.
In general it appears as if a condition like this:
select *
from t1
join t2 on FALSE
Is not correclty evaluated and returns an empty result set.
I informed the responsible development collegues about this.
Thanks a lot for pointing out!
regards,
Lars
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.