通过一些语句查询得到了一个表select BookName,BookNo, case Motion when '归还' then '在架' else '已借出' end as condition,Launcher as Borrower
from BorrowAndReturn 
where HistoryID in (select Max(HistoryID) from BorrowAndReturn group by BookNo)得到的表如下:
BookName    BookNo       condtion            Borrower
趣谈    31        在架          swer
就好    54        已借出          luck
的撒旦啊    321        在架          blamer现在我想把所有condition字段为‘在架’的记录中的Borrower字段改成‘无’,只在当前的语句里添加修改,怎么完成呢?

解决方案 »

  1.   

    select BookName,BookNo, case Motion when '归还' then '在架' else '已借出' end as condition,
    case Motion when '归还' then '无' else Launcher end Borrower
    from BorrowAndReturn  
    where HistoryID in (select Max(HistoryID) from BorrowAndReturn group by BookNo)
      

  2.   

    update BorrowAndReturn
    set Launcher ='无'
    where Motion ='归还' and HistoryID in (select Max(HistoryID) from BorrowAndReturn group by BookNo)
      

  3.   

    select BookName,BookNo, case Motion when '归还' then '在架' else '已借出' end as condition, case Motion when '归还' then '无' else Launcher end  as Borrower
    from BorrowAndReturn  
    where HistoryID in (select Max(HistoryID) from BorrowAndReturn group by BookNo)
      

  4.   

    当前的根本不是数据库表修改什么,其实还是修改原来是的数据库表。update borrowandreturn set
    borrower 'xxxx' where where 你搜索出来的条件。 
      

  5.   

    select BookName,BookNo, case Motion when '归还' then '在架' else '已借出' end as condition,case Motion where '归还' then '无' else Launcher end as Borrower
    from BorrowAndReturn  
    where HistoryID in (select Max(HistoryID) from BorrowAndReturn group by BookNo)