Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.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 如何在sql中修复此语法错误?_Mysql_Sql_Syntax Error - Fatal编程技术网

Mysql 如何在sql中修复此语法错误?

Mysql 如何在sql中修复此语法错误?,mysql,sql,syntax-error,Mysql,Sql,Syntax Error,1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解第3行的“按帐户排序的总资产数量\u名称限制0,30”附近使用的正确语法 作为总资产删除 SELECT account_name ,sum(total_balance) from transaction where account_name IN('cash','a/r','supplies','prepaid','land','gold') AS total_assets ORDER BY account_nam

1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解第3行的“按帐户排序的总资产数量\u名称限制0,30”附近使用的正确语法


作为总资产删除

SELECT account_name ,sum(total_balance) from transaction 
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
AS total_assets
ORDER BY account_name

你的别名放错地方了

SELECT account_name ,sum(total_balance) from transaction 
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
ORDER BY account_name
应该是

SELECT account_name ,sum(total_balance) from transaction 
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
AS total_assets
ORDER BY account_name

作为总资产
移动到
选择
子句中。这用于定义列别名:

SELECT account_name ,sum(total_balance) AS total_assets
from transaction 
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
ORDER BY account_name

我想你需要给
sum(总余额)命名为总资产
select account_name, sum(total_balance) as total_assets
from transaction 
where account_name in ('cash', 'a/r', 'supplies', 'prepaid', 'land', 'gold')
order by account_name;