找不到导致mysql语句错误的问题
因此,对于我拥有的这个特定mysql,我尝试将这两个表连接在一起,然后在连接表的另一列中选择具有最大值的名称。我怀疑问题在于我将两条语句连接在一起找不到导致mysql语句错误的问题,mysql,database,Mysql,Database,因此,对于我拥有的这个特定mysql,我尝试将这两个表连接在一起,然后在连接表的另一列中选择具有最大值的名称。我怀疑问题在于我将两条语句连接在一起 select ds_name from result where result.ds_sectionnumber = (select max(ds_sectionnumber) from result) from (select department.Dcode as ds_code, department.Dname as ds_name, s
select ds_name
from result
where result.ds_sectionnumber = (select max(ds_sectionnumber) from result)
from (select department.Dcode as ds_code, department.Dname as ds_name, section.Sectionnumber as ds_sectionnumber
from department join section on department.Dcode = section.Dcode) as result;
您的查询应该是:
select ds_name
FROM (select department.Dcode as ds_code,
department.Dname as ds_name,
section.Sectionnumber as ds_sectionnumber
FROM department
JOIN section on department.Dcode = section.Dcode) as result
WHERE ds_sectionnumber = (
select max(ds_sectionnumber) FROM
(select department.Dcode as ds_code,
department.Dname as ds_name,
section.Sectionnumber as ds_sectionnumber
FROM department
JOIN section
ON department.Dcode = section.Dcode) as result);
MySQL语句的
错误是什么?看起来您使用了太多来自
SY的。您的语法完全错误。完成子查询后,不能使用from子句。你想实现什么?这么多来自
s的??哇!提供模式并清楚地解释您想要的结果,以获得更好的答案!结果是另外两个的合并表,我试图获取任何具有最高section#值的行的名称,这是结果中的一个字段。对不起,我对mysql真的很陌生。在阅读关于子查询的章节之前,请尝试阅读关于联接的章节。不知怎的,它说表结果对我来说不存在。@Rozen try without where子句及其条件希望这来自where子句。如果没有where子句,它会给我ds_名称,但不带max sectionnumber条件。由于语法正确,我也不确定哪里有错。@Rozen我已经更新了答案,现在再检查一遍,它会对你有用。@草莓这是一个开放论坛,你可以编辑帖子,也可以更改,但请记住这应该是可行的。