marko c.
marko c.

Reputation: 385

Mysql Union in different columns

I have the following query

SELECT *
FROM(
        (SELECT 
            MAX(c.start_time) as start_1
        FROM 
            c1 c)
        UNION ALL
        (SELECT 
            MAX(cc.created_at) as ccmax
        FROM 
            cc1)
) as t

I'd like to have the result in a table with 2 columns start_1 and cmax instead of the single column I get with all the different results listed. How should I do it? I ended up in a subselect believing this would have done the job.

Upvotes: 0

Views: 86

Answers (1)

Madmartigan
Madmartigan

Reputation: 260

For the data to be in two columns you would have to use a sub select.

SELECT 
        MAX(c1.start_time) as start_1, (SELECT MAX(cc1.created_at) FROM cc1) as ccmax

FROM c1

Upvotes: 1

Related Questions