MySQL Forums
Forum List  »  InnoDB

3 Table Query
Posted by: Larry Regencia
Date: July 11, 2005 02:13AM

hello guys,

honestly, i don't know if I'm on the right section of forums since my questions are about queries. but please let me know if i am in the wrong section.

i would like to ask if you have any idea how should i do this query.. the scenario is like this: Table A, Table B, Table C.

Table A and Table B have common fields let say [accountcode], [transactioncode]
And these two tables are details of Table C which has also the field [accountcode]

What I wanted to retrieve from those tables A and B are data which match to Table C based on [accountcode], regardless they have a null value or not.

--------------------A -------------------------------- B -------------------------------- C
Tcode--ACode --Amount** Tcode--ACode--Amount ** AccountCode
1 --100 -- 100.00 ** 0 -- 100 -- 2100.00 ** 100
1 --101 -- 130.00 ** 0 -- 101 -- 4100.00 ** 101
1 --102 -- 150.00 ** 0 -- 102 -- 1100.00 ** 102
0 --103 -- 160.00 ** 1 -- 103 -- 3100.00 ** 103
0 --104 -- 200.00 ** 1 -- 104 -- 4100.00 ** 104
0 --105 -- 300.00 ** 1 -- 105 -- 5100.00 ** 105


Results if Transaction Code is 0:
Filter out transactioncode = 0
--------------------A -------------------------------- B -------------------------------- C
Tcode--ACode --Amount** Tcode--ACode--Amount ** AccountCode
NULL --100 -- NULL ** 0 -- 100 -- 2100.00 ** 100
NULL --101 -- NULL ** 0 -- 101 -- 4100.00 ** 101
NULL --102 -- NULL ** 0 -- 102 -- 1100.00 ** 102
0 --103 -- 160.00 ** NULL -- 103 -- NULL ** 103
0 --104 -- 200.00 ** NULL -- 104 -- NULL ** 104
0 --105 -- 300.00 ** NULL -- 105 -- NULL ** 105



please let me know if you have any ideas.. thanks in advance.

larry vincent

Options: ReplyQuote


Subject
Views
Written By
Posted
3 Table Query
2772
July 11, 2005 02:13AM
1998
July 11, 2005 05:39AM
1956
July 11, 2005 06:01PM
1927
July 11, 2005 06:35PM
1990
July 11, 2005 06:57PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.