如果我的coms集合中有文档格式:
{
"recipients": {
"key1": "value1",
"key2": "value2",
"key3": "value3",
}
}
我想获得所有具有完全相同键的文档。换句话说,在上面的例子中,如果我查询“key1”,“key2”,“key3”,我得到上面的文档。另一方面,如果我有以下文件:
{
"recipients": {
"key1": "value1",
"key2": "value2",
"key3": "value3",
"key4": "value4",
}
}
查询“key1”,“key2”,“key3”应该不返回任何内容。
答案 0 :(得分:0)
$存在的快速解决方案:
SELECT c.*, cs.*
FROM carts c
LEFT JOIN courses cs ON c.exam_id = cs.id
LEFT JOIN checks ch ON c.userid = ch.userid AND c.exam_id = ch.exam_id
WHERE c.userid = $id AND c.status ='Completed' AND ch.id IS NULL
但是这需要知道所有其他可能的键,并且写起来非常痛苦......