Home > OS >  Combining multiple Unions Queries - is this the best way?
Combining multiple Unions Queries - is this the best way?

Time:09-23

I've got some SQL code working at the moment but I need to do another union. I want to ensure what I do is correct. Currently, this is what I have:

    select * from (select * from stametadata
    union select * from stajjmetadata)

I want to union on another table. Would this be correct?

    select * from (select * from stametadata
    union select * from stajjmetadata
    union select * from staggmetadata)

Is this the neatest way to do it?

CodePudding user response:

You can chain unions. To be honest, you don't even need the outer query:

SELECT * FROM stametadata
UNION
SELECT * FROM stajjmetadata
UNION
SELECT * FROM staggmetadata
  • Related