在Ms Ms中,我可以创建一个名为“CustomerList”的查询,其中包含以下数据:
CustomerName, City, Revenue
然后我可以创建另一个查询,例如“CustomerCount”,如:
Select count(*) as Tot
from CustomerList ( <<<- is a query name)
where CustomerList.City
此查询基于另一个查询。是否有可能在MYSQL中做同样的事情?
由于
答案 0 :(得分:3)
是的,就像这样
Select count(*) as Tot
from
(
select City from some_table
) x
where x.City = 'NYC'
您必须为子查询添加别名。
答案 1 :(得分:3)
答案 2 :(得分:0)
您需要在嵌套查询中使用名为City
的列或别名
你只能这样做::
Select count(*) as Tot
from
/*
select City,..... your query
*/
CustomerList where CustomerList.City
答案 3 :(得分:0)
您可以使用子查询执行此操作。
select count(*) as Tot
from (
select City from some_table
) c
where c.City = 'YOURCITY'
在这种情况下, c
是子查询的别名。