How to use union all with manual value (not from another tabel)?

blankon91 picture blankon91 · May 24, 2012 · Viewed 12.7k times · Source

I want to use union all with manual value, not from another table. And the values are:

|cSatuan1|cSatuan2|nkonversi|
=============================
|   LTR  |   PCS  |    1    |
|   PCS  |   LTR  |    1    |

I've made the query with my own way, but it gets error. here is the query:

SELECT csatuan2, csatuan1, nkonversi
FROM ms_metriks union all select 'LTR','PCS','1','PCS','LTR','1'

Can you tell me what's wrong with my query, and what is the right query?

Answer

Marco picture Marco · May 24, 2012

Try this:

SELECT csatuan2,csatuan1,nkonversi FROM ms_metriks 
UNION ALL SELECT 'LTR','PCS','1'
UNION ALL SELECT 'PCS','LTR','1'