我在这里或Google找不到适合我的任何东西。
我尝试了以下代码:
delete from wms where barcode = '65025351102908' and '105077351106577';
值是要记住的varchar。
没有错误出现,但是0行受到影响。但是他们肯定在那里。
答案 0 :(得分:4)
您的WHERE
子句无法正常工作。您不能以这种方式分解条件
写此内容只会删除65025351102908
:
WHERE barcode = '65025351102908' and '105077351106577';
-- ^------------------------^ ^---------------^
-- Condition 1 Condition 2 (always true because different than a falsy value)
我想您想同时删除65025351102908
和105077351106577
这是通过使用OR(删除ID等于第一个OR或第二个ID)来完成的
尝试以下方法:
delete from wms where barcode = '65025351102908' or barcode = '105077351106577';
如果要删除大量裸代码,则可以使用IN
运算符:
delete from wms where barcode IN ('65025351102908', '105077351106577');
答案 1 :(得分:1)
您是否要删除具有这两个值的两行?
然后执行以下操作:
delete from wms
where (barcode = '65025351102908') or (barcode = '105077351106577');
您也可以这样做:
delete from wms
where barcode in ('65025351102908','105077351106577');
答案 2 :(得分:0)
如果您要删除这些值之间的“中间”(请注意,您要将它们写在单引号内作为字符串),则语法可能会像这样更好:
delete from wms where barcode BETWEEN '65025351102908' and '105077351106577';