MySql多个删除语句

问题描述 投票:-1回答:3

我在这里找不到任何东西或google对我有用。

我试过以下代码:

delete from wms where barcode = '65025351102908' and '105077351106577';

值是一个varchar熊。

没有错误,但0行受到影响。但他们肯定在那里。

mysql sql sql-delete
3个回答
4
投票

您的WHERE条款没有按预期工作。你不能这样分解条件

写这个只会删除qazxsw poi:

65025351102908

我想你要删除WHERE barcode = '65025351102908' and '105077351106577'; -- ^------------------------^ ^---------------^ -- Condition 1 Condition 2 (always true because different than a falsy value) 65025351102908

这是使用OR完成的(删除id等于第一个或第二个)

试试这个:

105077351106577

如果要删除大量裸代码,可以使用delete from wms where barcode = '65025351102908' or barcode = '105077351106577'; 运算符:

IN

1
投票

您是否尝试使用这两个值删除这两行?

然后这样做:

delete from wms where barcode IN ('65025351102908', '105077351106577');

你也可以这样做:

delete from wms 
where (barcode = '65025351102908') or (barcode = '105077351106577');

0
投票

如果你想删除那些值之间的“之间”(考虑到你将它们作为字符串写在单引号中),你的语法可能会更好:

delete from wms 
where barcode in ('65025351102908','105077351106577');
© www.soinside.com 2019 - 2024. All rights reserved.