select a.*,
(select isagree,checkdate from b where b.levs=1 and a.otID=b.otID),
(select isagree,checkdate from b where b.levs=2 and a.otID=b.otID),
(select isagree,checkdate from b where b.levs=3 and a.otID=b.otID),from a----------------------------------
这样取出来isagree,checkdate 是无列名的 怎么给他起别名?isagree as deptIsagree,checkdate as deptIscheckdate 这样不行啊
--
莫非只能对isagree,checkdate 一个一个查询 然后 在再起别名

解决方案 »

  1.   

    莫非只能对isagree,checkdate 一个一个查询 然后 在再起别名
    是这样
      

  2.   

    楼主可以可以把A,B表做个链接
    SELECT A.*,B.isagree,B.checkdate FROM A JOIN B ON A.otID=B.otID WHERE B.levs IN(1,2,3) 
      

  3.   

    select isagree,checkdate from b where b.levs=1 and a.otID=b.otID)
    --怎么返回两列 ,只能为一列取别名
      

  4.   

    若是有多个单词组成的话,要给别名加引号-----------------------------------
    http://www.jiemengwu.com/ 解梦屋 http://www.phpzy.com/php/ 绿色php资源
      

  5.   

    可以直接select b.checkdata,b.isagreet from a ,back as b .这样不就行了吗