首先:
select id, lb, subject, nowuser from listlb有三个状态1,2,3
lb为3时继续查询表中字段,把done='ready' and xh=’1’ 与其他的结果区分开有办法统一到一个sql语句中吗?

解决方案 »

  1.   

    最后要得到的是从list表中查询的结果
    以lb区分结果
    lb为3种状态,应该得到三种结果
    我现在想再查询表,将lb=3的状态再分为两种状态list 和 表有一项id是一样的值
      

  2.   

    select id, lb, subject, nowuser from model_list where lb in (1,2,3)当lb=3时再执行下面的语句判断m2.done='ready' and xh=’1’这两个条件是否成立 select m1.id from model_list m1,model_ m2 where m1.id=m2.mid and m1.author=’用户名’ and m2.done='ready' and xh=’1’ 
      

  3.   


    select a.lb, decode(b.done, 'ready', decode(b.xh, '1', '1', '0'), '0') /*加上单行函数*/
    from list a,  b
    where a.id = b.id
    group by a.lb, decode(b.done, 'ready', decode(b.xh, '1', '1', '0'), '0')