Mysql错误消息:1242子查询返回超过1行

时间:2016-04-28 06:59:13

标签: mysql subquery

我在数据库中有两个表,我有问题

当我在mysql中推荐它时,它可以工作

    select 
    (select deptno.`FName` 
        from deptno where deptno.`FID` = person.`Unit1No`) as  dept
            from person,leavemonth WHERE person.PsnNo = leavemonth.PsnNo

但是当我选择这个条件时, 它给我一个像问题标题

的消息
        select 
        (SELECT leavemonth.`H08` FROM leavemonth where leavemonth.`PsnNo` = person.`PsnNo` )
            as H08
    from person,leavemonth WHERE person.PsnNo = leavemonth.PsnNo

我尝试了许多方法并尝试回答,但总是失败,

有人可以教我并告诉我如何解决它吗?

1 个答案:

答案 0 :(得分:1)

它适合你

select l.H08 as H08
from person p
inner join leavemonth l on p.PsnNo = l.PsnNo