In the development of the search interface, we often encounter scenarios that require fuzzy matching, and record how MySQL and MongoDB do it respectively.
Compared
-- SQL:
SELECT * FROM users WHERE username LIKE "%l%"
-- MongoDB:
db.users.find({username: /l/})
// 或者
db.users.find({username: { $regex: 'l'})
LIKE fuzzy query for data whose username starts with the letter "Zhang" (Zhang%)
-- SQL:
SELECT * FROM users WHERE username LIKE "张%"
-- MongoDB:
db.users.find({username: /^张/})
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。