|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 |
|
Messages: n/a
Hébergeur: |
Hi, I think this should be obvious, but I'm having problems with it.
Can anyone ? I have 2 tables like this: table1: date amount 2007-10-01 5.00 2007-10-01 3.50 2007-10-02 1.80 table2: date amount 2007-10-01 6.30 2007-10-02 4.20 2007-10-03 9.60 I simply want to combine these tables so the output looks like this (row order is not important): date amount1 amount2 2007-10-01 5.00 0 2007-10-01 3.50 0 2007-10-02 1.80 0 2007-10-01 0 6.30 2007-10-02 0 4.20 2007-10-03 0 9.60 I think that UNION is the way to go, but I'm having trouble forming the correct query. If anyone could advise I'd be grateful for the . Thanks, Mike. |
|
|
|
#2 |
|
Messages: n/a
Hébergeur: |
On Sun, 14 Oct 2007 00:25:02 +0200, Mike Harrison <mjh626@yahoo.co.uk>
wrote: > Hi, I think this should be obvious, but I'm having problems with it. > Can anyone ? > > I have 2 tables like this: > > table1: > date amount > 2007-10-01 5.00 > 2007-10-01 3.50 > 2007-10-02 1.80 > > table2: > date amount > 2007-10-01 6.30 > 2007-10-02 4.20 > 2007-10-03 9.60 > > I simply want to combine these tables so the output looks like this > (row order is not important): > > date amount1 amount2 > 2007-10-01 5.00 0 > 2007-10-01 3.50 0 > 2007-10-02 1.80 0 > 2007-10-01 0 6.30 > 2007-10-02 0 4.20 > 2007-10-03 0 9.60 > > I think that UNION is the way to go, but I'm having trouble forming > the correct query. If anyone could advise I'd be grateful for the > . SELECT date, amount as 'amount1', 0 as 'amount2' FROM table1 UNION SELECT date, 0 as 'amount1', amount as 'amount2' FROM table2 -- Rik Wasmus |
|
![]() |
| Outils de la discussion | |
|
|