MYSQL 中 LIKE 和 = 的区别?
2021-11-20 00:00:00
mysql
有什么区别
SELECT foo FROM bar WHERE foobar='$foo'
和
SELECT foo FROM bar WHERE foobar LIKE'$foo'
推荐答案
LIKE 可以做通配符匹配:
LIKE can do wildcard matching:
SELECT foo FROM bar WHERE foobar LIKE "Foo%"
如果您不需要模式匹配,则使用 = 而不是 LIKE.它更快,更安全.(您使用的是参数化查询,对吗?)
If you don't need pattern matching, then use = instead of LIKE. It's faster and more secure. (You are using parameterized queries, right?)
相关文章