我有个问题:
是否可以在一个查询中收集多个查询?
即在表单中我有 10 个这样的查询:
1. SELECT ThisValue FROM thatTable1 WHERE
2. SELECT ThisValue FROM thatTable2 WHERE
.......
10. SELECT ThisValue FROM thatTable10 WHERE
我应该在哪里编写,即在 Access 中编写此代码。它可能在 Access 中,或者只有我可以在 MS SQL 中这样做,并且......
CREATE PROC dbo.proc_app_CollectControlData
AS
SET NOCOUNT ON
DECLARE @t TABLE
(
CONTROLNAME nvarchar(74),
CONTROLVALUE nvarchar(255)
)
-- Now we collect the data for the 10 different controls
INSERT INTO @t
(CONTROLNAME, CONTROLVALUE)
SELECT 'MyFirstControl',
ThisValue
FROM dbo.ThatTable
WHERE Condition1
...
INSERT INTO @t
(CONTROLNAME, CONTROLVALUE)
SELECT 'MyTenthControl',
ThisValue
FROM dbo.ThatTable
WHERE Condition10
-- And now we return all found data to the client
SELECT * FROM @
SET NOCOUNT OFF
GO