|
▼さつき さん:
>ユニオンクエリ↓
>SELECT "a"& format((SELECT COUNT(*) FROM [aa] AS [aaaa] WHERE [aaaa]![ID] <= [aa]![ID]),"0000") AS 連番, aa.質問, aa.回答, aa.リンク
>FROM aa;
>
>UNION SELECT "b" & format((SELECT COUNT(*) FROM [bb] AS [bbbb] WHERE [bbbb]![ID] <= [bb]![ID]),"0000") AS 連番, bb.質問, bb.回答, bb.リンク
>FROM bb;
ユニオンクエリ じゃなくすればよろしいかと。
SELECT A.連番, A.質問, A.回答, A.リンク FROM (
SELECT "a"& format((SELECT COUNT(*) FROM [aa] AS [aaaa] WHERE [aaaa]![ID] <= [aa]![ID]),"0000") AS 連番, aa.質問, aa.回答, aa.リンク
FROM aa
UNION ALL
SELECT "b" & format((SELECT COUNT(*) FROM [bb] AS [bbbb] WHERE [bbbb]![ID] <= [bb]![ID]),"0000") AS 連番, bb.質問, bb.回答, bb.リンク
FROM bb
) AS A
ORDER BY A.連番;
UNION は、重複削除処理が無駄に走りますので、
UNION ALL にしましょう。
|
|