MySQL Forums
Forum List  »  Newbie

UNION or JOIN?
Posted by: Augusto César
Date: August 11, 2006 08:36AM

Hey all! Long time, no see!

I am having a big problem with two tables and I cant get the result I want.

The tables are:
Table A
A1 - A2 - A3
1 - 9 - 2
1 - 10 - 2
2 - 9 - 3
2 - 10 - 3
3 - 9 - 2
3 - 10 - 2

Table B
B1 - B2 - B3
1 - 8 - 1
2 - 9 - 1
3 - 10 - 0
4 - 9 - 1

What I want is:
Table results:
R1 - R2 - R3
1 - 8 - 1
1 - 9 - 2
1 - 10 - 2
2 - 9 - 3
2 - 10 - 3
3 - 9 - 2
3 - 10 - 0
4 - 9 - 1

Explaing the R table:
R2 - A2 || B2
R3 - if(B2 && A2) B3 * A3; else B3 or A3;

I tried to use JOIN and it gave some results, the UNION gave me the results that JOIN missed.

So, the problem is, I do not know how to get those results, could anyone help me please?

See ya!

Augusto

Options: ReplyQuote


Subject
Written By
Posted
UNION or JOIN?
August 11, 2006 08:36AM
August 11, 2006 09:34AM
August 11, 2006 11:38AM
August 11, 2006 12:07PM


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.