新手请教各位高人:我有如下张表:请问怎样才能的到后面页面显示的结果,注:用户登陆后查询与其相关的任务信息,包括自己是管理人的任务信息和自己是执行人的任务信息任务信息表:任务进度表:想要的结果:

解决方案 »

  1.   

    建你贴出数据这样方便表达和测试结果。select t.taskid, t.manaidfk, p.execidfk,p.percent,t.endtime
    from 任务信息表 t,任务进度表 p
    where t.taskid=p.t.taskidFk
    where t.manaidfk='xxx'
    and p.execidfk='zzz'
      

  2.   

    上面语句多了个where,换成andselect t.taskid, t.manaidfk, p.execidfk,p.percent,t.endtime
    from 任务信息表 t,任务进度表 p
    where t.taskid=p.t.taskidFk
    and t.manaidfk='xxx'
    and p.execidfk='zzz'
      

  3.   

    或者用join , inner join 或者 left join 根据你实现情况选择select t.taskid, t.manaidfk, p.execidfk,p.percent,t.endtime
    from 任务信息表 t left join 任务进度表 p on t.taskid=p.t.taskidFk
    where t.manaidfk='xxx'
    and p.execidfk='zzz'
      

  4.   


    select t.taskid, t.manaidfk, p.execidfk,p.percent,t.endtime
    from 任务信息表 t,任务进度表 p
    where t.taskid=p.t.taskidFk
    and t.manaidfk='xxx'
    and p.execidfk='zzz'