修正一下,最后的查询结果是
    name
     c1并且每次的查询条件都不知道code的值是多少
也就是说查询语句中的查询条件必须是code=StrCode(StrCode是code值)

解决方案 »

  1.   

    我想要一个比较简单的sql语句就能查询出来结果语句越短越好
      

  2.   

    select c.name ,d.code from 表d d,表c c where d.no3 = c.no3 and d.no1 = c.no1 and d.no2 = c.no2
    union
    select b.name ,d.code from 表d d,表b b where  d.no1 = b.no1 and d.no2 = b.no2 and d.no3 is null
    union
    select a.name ,d.code from 表d d,表a a where  d.no1 = a.no1 and d.no2 is null
      

  3.   

    设计表严重不合理,假如表d记录往下递增,字段也递增,岂不是接着创建表,为什不把code与name对应起来
    表e(code,name)
    001  a
    002  b
    003  c
      

  4.   

    吸取beckhambobo(beckham) 的提议,结贴。