delete a
from a 
join b on a.a_bid=b.id where b.b_cid=10

解决方案 »

  1.   

    delete a.* from a 
    join b on a.a_bid=b.id where b.b_cid=10
      

  2.   

    delete from a where a_bid in (select id from b where b_cid=10)
      

  3.   

    方法很多:
    delete from a where exists(select id from b t where t.b_cid=10 and t.id=a.a_bid)
      

  4.   

    如果是單獨表,可用:
    delete from a  
    or
    truncate table a  --速度快,不寫日志關聯表:
    delete a
    from a 
    inner join b on a.a_bid=b.id 
    where b.b_cid=10
      

  5.   

    请问如何在update语句中 实现更改指定纪录的时间中的小时数值只修改小时,保留原来的年,月,日,分钟等数据,请问如何写sql语句
      

  6.   

    --增加一小时
    update  表 set 日期字段=dateadd(hour,1,日期字段)--减少一个小时
    update  表 set 日期字段=dateadd(hour,-1,日期字段)
      

  7.   

    --将小时修改成指定的小时
    declare @hour int
    set @hour=12  --假设设置成12点update 表 set 日期字段=dateadd(hour,@hour-datepart(hour,日期字段),日期字段)
      

  8.   

    是这样吗?
    修改 小时=12的记录
    update 字段=‘某值’where datepart(hour,日期字段)=12
      

  9.   

    老大们帮忙,需要问一下如何在sql server数据库里把时间恢复到零点
      

  10.   

    delete a from a join b on a.a_bid=b.id where b.b_cid=10