0
我有這個查詢在同一個數據庫的多個表上執行,所有數據庫的結構都是相同的。 基本上,查詢找出Table_xxx中列出的代碼,這些代碼不存在於表格「Components」中。從查詢數據的表名中獲取表名的SQL查詢
SELECT DISTINCT a.Code, a.Description, a.Quantity FROM Table_321 AS a
WHERE NOT EXISTS (SELECT * FROM Components where Components.Code = a.Code)
UNION ALL
SELECT DISTINCT a.Code, a.Description, a.Quantity FROM Table_333 AS a
WHERE NOT EXISTS (SELECT * FROM Components where Components.Code = a.Code)
UNION ALL
.............
.............
order by Code
我怎樣才能得到最初包含「代碼,描述和數量」的表名?
非常感謝。這十分完美! – Nullbyte