Anda telah menandai pertanyaan Anda sebagai MySQL dan Anda menggunakan tanda kurung siku []
. Sejauh yang saya tahu, tanda kurung siku bukan berlaku untuk MySQL dan hanya berlaku untuk produk Microsoft (SQL Server/MS Access). Jadi jika Anda perlu menyertakan nama tabel/kolom gunakan backticks `
.
Jadi menurut saya kueri Anda seharusnya:
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`;
Sunting, jika Anda menggunakan MS Access maka Anda harus menggunakan tanda kurung siku:
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];