I've two tables TAB_A and TAB_B. TAB_A is master table and TAB_B is child / transaction table. TAB_A is having COL_A (Primary key) and TAB_B is having COL_B (Primary key) and also COL_A.
For some business reason, Foreign key is not defined between TAB_A and TAB_B on column COL_A.
I've four records in TAB_B with some values say 1, 2, 3 and 4 in COL_A which has got no corresponding matching values in COL_A of TAB_A. (They are orphan records, created by mistake)
When I issue the following SELECT query, I get four records
SELECT B.COL_B, B.COL_A FROM TAB_A A, TAB_B B WHERE A.COL_A = B.COL_A AND B.COL_A IN (1, 2, 3, 4)
But if I start refering A.COL_A in SELECT query, no records are returned.
SELECT B.COL_B, B.COL_A, A.COL_A FROM TAB_A A, TAB_B B WHERE A.COL_A = B.COL_A AND B.COL_A IN (1, 2, 3, 4)
Can someone please explain this weird behavior?
DB2 Version 9.5 in AIX