因此,对于我拥有的这个特定mysql,我尝试将这两个表连接在一起,然后在连接表的另一列中选择具有max值的名称。我怀疑问题是我把两个陈述联系在一起。
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 - 无法找到导致mysql语句错误的问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20116528/