当前位置:主页>销售管理软件> 列表

求一sql删除语句! 找傻瓜进销存破解

财务软件版1楼: Access数据库xh如下
字段 P1 P2 P3
0 0 0
0 0 1
…………….
9 9 9
从数据库中删除不包含指定几个数字(如1,6,8,9)的记录,sql语句怎么写?
Delete from xh where ?

2楼: Delete from xh where (p1 not in(1,6,8,9)) and ..... 如傻瓜进销存破解

3楼: delete from xh
where (CharIndex(''1'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0)
and (CharIndex(''6'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0)
and (CharIndex(''8'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0)
and (CharIndex(''9'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0)

4楼: royal1442的方法应该可行。

5楼: CharIndex这个函数有什么功能?我觉得子瑜的方法行得通,可惜没有装着access要不就可以试试了。

6楼: 学习了下,很不错。

财务软件版7楼: 如果1,6,8,9用integer变量a''b''c''d代替,SQL语句中怎么用?


A:=1;B:=6;C:=8;D:=9;
p1 not in(A,B,C,D)好像行不同,是不是得变成string型?

8楼: Format(''delete from xh ''
+''where (CharIndex(''%S'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0)''
+'' and (CharIndex(''%S'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0) ''
+'' and (CharIndex(''%S'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0)''
+'' and (CharIndex(''%S'', (Convert(Char, P1) + Convert(Char, P2) + Convert(Char, P3))) <= 0) '',
[IntTostr(A),IntTostr(B),IntTostr(C),IntTostr(D)])

9楼: p1 not in(1,6,8,9)) 只是说某个字段不等于这几个值,但你的要求是某个字段不包含某几个值,所以必须用charIndex,这个函数类似delphi里的pos.

10楼: 数据都是单个的,p1 not in 就够用了,谢谢babibean的讲解!

11楼: 多人接受答案了。