質問にMySQLのタグを付け、角かっこを使用しています[]
。私の知る限り、角かっこはではありません。 MySQLで有効であり、Microsoft製品(SQL Server / MS Access)でのみ有効です。したがって、テーブル/列名を囲む必要がある場合は、バッククォート`
を使用してください 。
したがって、クエリは次のようになります。
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`;
編集します。MSAccessを使用している場合は、角かっこを使用する必要があります。
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];