Du har tagget dit spørgsmål som MySQL, og du bruger firkantede parenteser []
. Så vidt jeg ved, er firkantede parenteser ikke gyldige for MySQL og er kun gyldige for Microsoft-produkter (SQL Server/MS Access). Så hvis du har brug for at vedlægge tabel-/kolonnenavn, brug backticks `
.
Så jeg synes, din forespørgsel skal være:
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`;
Rediger, hvis du bruger MS Access, skal du bruge de firkantede parenteser:
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];