Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在寻找 MySQL 的等价物
SELECT * FROM table WHERE field1 LIKE '%somestring%' AND field2 LIKE '%anotherstring%'
我确实尝试了几件事,包括
'field1' => '/somestring/i', 'field2' => '/anotherstring/i'
我没有得到任何结果,或者只是基于两个字段之一的数据。这在 MongoDB 中是不可能的吗?
db.collection.find({field1: {$regex: /somestring/i}, field2: {$regex: /anotherstring/i}});
In php you should do by MongoRegex.
php
MongoRegex
array(field1 => new MongoRegex("/somestring/i"), field2 => new MongoRegex("/anotherstring/i"))