As soon as I posted I found the example.. ;)

the answer was to use a UNION

http://www.w3schools.com/sql/sql_union.asp


SELECT DATA1STAMP as DATASTAMP , DATA1DATA as DATA from DATATABLE
UNION
SELECT DATA2STAMP as DATASTAMP , DATA2DATA as DATA from DATATABLE;

This makes a union and puts the data in the correct columns on my return.. 
Now I can

SELECT * from (SELECT DATA1STAMP as DATASTAMP , DATA1DATA as DATA from 
DATATABLE
UNION
SELECT DATA2STAMP as DATASTAMP , DATA2DATA as DATA from DATATABLE)
WHERE DATASTAMP > NOW();


Thanks, I hope  this helps some one.






[EMAIL PROTECTED] 
03/06/2008 09:14 AM

To
Lucas CTR Heuman/ACT/CNTR/[EMAIL PROTECTED]
cc
<mysql@lists.mysql.com>
Subject
Re: Formatting in same columns when selecting from two tables.






Good Morning Lucas-
could you define the formatting specifics of DATA and DATASTAMP 
result-type?
Thank You
Martin
----- Original Message -----
Wrom: REXCAXZOWCONEUQZAAFXISHJEX
To: <mysql@lists.mysql.com>
Sent: Thursday, March 06, 2008 8:43 AM
Subject: Formatting in same columns when selecting from two tables.


> I have a table in my database with 4 fields, Because it is already
> implemented in the application I am modifying I cannot change the table.
> Here is what I have
> DATA1STAMP type DATE  , DATA1DATA type INTEGER, DATA2STAMP type DATE,
> DATA2DATA type INTEGER in my DATATABLE.
>
> I now need to select this and format the results as
> DATA , DATASTAMP in two columns when selecting from this table to 
report.
> Can I join on the same table in a way that the data can format 
correctly?
>
>
> My plan is to try and use a Sub select kinda like SELECT * from (SELECT
> DATA1STAMP as DATASTAMP,  DATA1DATA as DATA from DATATABLE) and (SELECT
> DATA2STAMP as DATASTAMP,  DATA2DATA as DATA from DATATABLE) WHERE
> DATASTAMP < NOW();
>
> I'm not sure if this can be done.. any ideas?
>
>


Reply via email to