Svou otázku jste označili jako MySQL a používáte hranaté závorky []
. Pokud vím, hranaté závorky nejsou platné pro MySQL a jsou platné pouze pro produkty společnosti Microsoft (SQL Server/MS Access). Pokud tedy potřebujete uzavřít název tabulky/sloupce, použijte backticks `
.
Takže si myslím, že váš dotaz by měl znít:
SELECT `Ordine numero` AS ordine, `data ordine` AS data, comm AS commessa
FROM `archivio globale`
WHERE `ordine numero` IS NOT NULL
UNION ALL
SELECT `numero ordine cliente` AS ordine, `data ordine cliente` AS data, numero AS commessa
FROM `ricambi`
WHERE `numero ordine cliente` IS NOT NULL
UNION ALL
SELECT `numero ordine cliente` AS ordine, `data ordine cliente` AS data, numero AS commessa
FROM `trasferte`
WHERE `numero ordine cliente` IS NOT NULL
ORDER BY `ordine`;
Upravte, pokud používáte MS Access, budete muset použít hranaté závorky:
SELECT *
FROM
(
SELECT [Ordine numero] AS ordine, [data ordine] AS data, comm AS commessa
FROM [archivio globale]
WHERE [ordine numero] IS NOT NULL
UNION ALL
SELECT [numero ordine cliente] AS ordine, [data ordine cliente] AS data, numero AS commessa
FROM [ricambi]
WHERE [numero ordine cliente] IS NOT NULL
UNION ALL
SELECT [numero ordine cliente] AS ordine, [data ordine cliente] AS data, numero AS commessa
FROM [trasferte]
WHERE [numero ordine cliente] IS NOT NULL
) x
ORDER BY [ordine];