Question : Add Alias to Union query

I have the following union query:

SELECT ProductId, ProductCode, ProductDescription  FROM qryProductsStockTakeAdjustmentReport UNION SELECT Ast, Desc FROM tblAsterisk
ORDER BY Productcode;

It does not run because the number of columns do not match. How do I add an alias to get the same numbe rof columns on each side?

Answer : Add Alias to Union query

For example, add Null:

SELECT ProductId, ProductCode, ProductDescription  FROM qryProductsStockTakeAdjustmentReport UNION SELECT Ast, [Desc], Null FROM tblAsterisk
ORDER BY Productcode;

Note: DESC is a reserved keyword.

(°v°)
Random Solutions  
 
programming4us programming4us