没有FROM子句的SELECT [英] SELECT without FROM Clause
问题描述
我正在为我的MS Access数据库编写一条SQL语句,目的是对3个不同查询中的值进行计数,所以我尝试了这种方式:
SELECT(query1 + query2 + query3)AS Qtd
每个查询从聚合函数计数中返回唯一值,即 query1 = SELECT WHERE表中的Count(某物)...
一切正常,但MS Access要求 FROM
子句.当我在该查询中放置一个表(不更改上面的 SELECT
语句)时,我最终得到行的色调,并且每一行都是 Qtd
列期望的结果.>
所以有什么方法可以跳过 FROM
子句,或者唯一的解决方法是将 TOP 1
(或 DISTINCT
)写入是否由于 FROM
子句中不必要的表而获得重复行的提示音?
考虑聚合查询的交叉联接(用逗号分隔的表):
SELECT(query1.CntColumn + query2.CntColumn + query3.CntColumn)AS Qtd从query1,query2,query3
I'm writing a SQL statement for my MS Access database, and the purpose is to count values from 3 different queries, so I tried this way:
SELECT(query1 + query2 + query3) AS Qtd
Each query returns an unique value from an aggregate function count, i.e, query1 = SELECT Count(something) FROM Table WHERE...
Everything should work fine, but MS Access demands a FROM
clause. When I put a table in that query (not changing the SELECT
statement above), I end up with tones of rows and each row the result expected from Qtd
column.
So is there any way to skip the FROM
Clause or the only option to work around is write TOP 1
(or DISTINCT
) to not get tones of duplicated rows because of the unnecessary table in FROM
clause?
Consider the cross join (comma separated tables) of the aggregate queries:
SELECT (query1.CntColumn + query2.CntColumn + query3.CntColumn) AS Qtd
FROM query1, query2, query3
这篇关于没有FROM子句的SELECT的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!