What's the command to achieve this:
MYSQL: delete all rows containing string "foo"
in table "bar"
实现此目的的命令是什么:MYSQL:删除表“bar”中包含字符串“foo”的所有行
6 个解决方案
#1
42
DELETE FROM bar where
field1 like '%foo%'
OR
field2 like '%foo%'
OR
...
fieldLast like '%foo%'
#2
5
You'll need to explicitly list the columns I think, so something along the lines of...
你需要明确列出我认为的列,所以有些东西......
DELETE FROM bar WHERE col1 LIKE '%foo%' OR col2 LIKE '%foo%'....etc
#3
2
Normally, you can use the 'LIKE' keyword to perform simple pattern matching: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
通常,您可以使用'LIKE'关键字来执行简单的模式匹配:http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
#4
2
Try this query
试试这个查询
delete from [table name] where [column name] like '%[text to find]%'
This will match if the text appears, regardless of position. i.e.
无论位置如何,如果文本出现,这将匹配。即
if you were looking for foo, it would match "xfoo
" and "foox
"
如果你正在寻找foo,它会匹配“xfoo”和“foox”
#5
1
The query and explaination can be found here (see question 2)
查询和解释可以在这里找到(见问题2)
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/the-ten-most-asked-sql-server-questions--1#2
You may also need to change the comparative condition to "like" condition.
您可能还需要将比较条件更改为“喜欢”条件。
#6
0
delete from bar where field1 like '%foo%' OR field2 like '%foo%' OR ... fieldLast like '%foo%'
#1
42
DELETE FROM bar where
field1 like '%foo%'
OR
field2 like '%foo%'
OR
...
fieldLast like '%foo%'
#2
5
You'll need to explicitly list the columns I think, so something along the lines of...
你需要明确列出我认为的列,所以有些东西......
DELETE FROM bar WHERE col1 LIKE '%foo%' OR col2 LIKE '%foo%'....etc
#3
2
Normally, you can use the 'LIKE' keyword to perform simple pattern matching: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
通常,您可以使用'LIKE'关键字来执行简单的模式匹配:http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html
#4
2
Try this query
试试这个查询
delete from [table name] where [column name] like '%[text to find]%'
This will match if the text appears, regardless of position. i.e.
无论位置如何,如果文本出现,这将匹配。即
if you were looking for foo, it would match "xfoo
" and "foox
"
如果你正在寻找foo,它会匹配“xfoo”和“foox”
#5
1
The query and explaination can be found here (see question 2)
查询和解释可以在这里找到(见问题2)
http://blogs.lessthandot.com/index.php/DataMgmt/DataDesign/the-ten-most-asked-sql-server-questions--1#2
You may also need to change the comparative condition to "like" condition.
您可能还需要将比较条件更改为“喜欢”条件。
#6
0
delete from bar where field1 like '%foo%' OR field2 like '%foo%' OR ... fieldLast like '%foo%'