求一条语句

wuszh1688 2011-02-21 01:57:46
数据结构:
name shuxing date
lixiao 0(IPV6) 2011-01-01
lixiao 0(IPV4) 2011-01-01
lixiao 0 2011-01-01

susan 20(IPV6) 2011-01-01
susan 20(IPV4) 2011-01-01
susan 20 2011-01-01



sz 0+max(ss-2000)(IPV6) 2011-01-01
sz 0+max(ss-2000)(IPV4) 2011-01-01
sz 0+max(ss-2000) 2011-01-01


如何删除日期为2011-01-01号的,且shuxing的值里不包含(IPV6),(IPV4)的记录,我要的结果是:



name shuxing date
lixiao 0(IPV6) 2011-01-01
lixiao 0(IPV4) 2011-01-01

susan 20(IPV6) 2011-01-01
susan 20(IPV4) 2011-01-01



sz 0+max(ss-2000)(IPV6) 2011-01-01
sz 0+max(ss-2000)(IPV4) 2011-01-01
...全文
73 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
javatemptation 2011-02-21
  • 打赏
  • 举报
回复

use tempdb;
/*
create table test
(
name nvarchar(10) not null,
shuxing nvarchar(50) not null,
[date] date not null
);
insert into test(name,shuxing,[date])
values
('lixiao','0(IPV6)','2011-01-01'),
('lixiao','0(IPV4)','2011-01-01'),
('lixiao','0','2011-01-01'),
('susan','20(IPV6)','2011-01-01'),
('susan','20(IPV4)','2011-01-01'),
('susan','20','2011-01-01'),
('sz','0+max(ss-2000)(IPV6)','2011-01-01'),
('sz','0+max(ss-2000)(IPV4)','2011-01-01'),
('sz','0+max(ss-2000)','2011-01-01');
*/
delete
from test
where [date] = '2011-01-01'
and shuxing not like '%(IPV6)%'
and shuxing not like '%(IPV4)%';
wuszh1688 2011-02-21
  • 打赏
  • 举报
回复
谢谢一楼的,正确!
明天结贴,当天还不能结
yan267 2011-02-21
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 yan267 的回复:]
SQL code

delete from [TABLE] where DATEDIFF (day,[date],'2011-01-01')=0 and shuxing
not like '%(IPV6)%' and shuxing not like '%(IPV4)%'
[/Quote]

写错,应该是:

delete from [TABLE] where DATEDIFF (day,[date],'2011-01-01')=0 and (shuxing
not like '%(IPV6)%' or shuxing not like '%(IPV4)%')
liang145 2011-02-21
  • 打赏
  • 举报
回复
delete from tableName where date='2011-01-01' and shuxing not like '%(IPV6)%' and shuxing not like '%(IPV4)%'
liang145 2011-02-21
  • 打赏
  • 举报
回复

select * from tableName where date='2011-01-01' and (shuxing like '%(IPV6)%' or shuxing like '%(IPV4)%'
yan267 2011-02-21
  • 打赏
  • 举报
回复

delete from [TABLE] where DATEDIFF (day,[date],'2011-01-01')=0 and shuxing
not like '%(IPV6)%' and shuxing not like '%(IPV4)%'

34,594

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧