Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/64.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 内部联接3表pl/sql_Mysql_Sql - Fatal编程技术网

Mysql 内部联接3表pl/sql

Mysql 内部联接3表pl/sql,mysql,sql,Mysql,Sql,基本上,我希望内部连接3个表,查询本身对这种情况的理解如下 表: A has 2 columns column 1 and column 2 B has 2 columns column 3 and column 4 C has 3 columns column 5,column 6 and column 7 查询: select A.column1, C.Count(C.column6) from table1 as A inner join table3 as C on A.colum

基本上,我希望内部连接3个表,查询本身对这种情况的理解如下

表:

A has 2 columns column 1 and column 2 
B has 2 columns column 3 and column 4
C has 3 columns column 5,column 6 and column 7
查询:

select A.column1, C.Count(C.column6) 
from table1 as A inner join table3 as C on A.column2 = C.column5 
inner join table2 as B on C.column5 = B.column4 and column3 = 'abcd' 
where column7 > NOW() - Interval '30 days' 
group by C.column5 
order by C.count(column5) desc 
但是我得到一个错误,模式C不存在


为什么会这样?查询有错误吗?

问题在于,您使用的别名是
C
,而您不应该在该别名中使用
count
功能。这:

C.Count(C.column6)
应该是:

Count(C.column6)
同样的更改也适用于order by子句(这可能是计算错误的列-是否应该是第6列?):

按计数排序(第5列)说明
->
按计数排序(第6列)说明

另外:您应该引用
GROUPBY
子句中的所有非聚合列,因此它可能应该是
GROUPBY A.column1