V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
推荐工具
RoboMongo
推荐书目
50 Tips and Tricks for MongoDB Developers
Related Blogs
Snail in a Turtleneck
sigmadog
V2EX  ›  MongoDB

这样的查询能实现吗?

  •  
  •   sigmadog · Mar 17, 2014 · 4997 views
    This topic created in 4433 days ago, the information mentioned may be changed or developed.
    mongodb 初学者,碰到一个问题,
    数据如下,会有多个数据的parent值相同
    {
    --"site": "abc",
    ---"item": {
    ----"id": "123",
    ----"parent": "234",
    ----"title": "xxxxxxxxx",
    ---},
    --"_id": "1234567890"
    }
    现在要查出_id为1234567890,1234567891,1234567892,但对于parent相同的,只保留一个。
    4 replies    1970-01-01 08:00:00 +08:00
    binux
        1
    binux  
       Mar 17, 2014
    distinct?
    sigmadog
        2
    sigmadog  
    OP
       Mar 17, 2014
    @binux distinct 好像只能过滤出不同的parent?我想获得所有parent不同的记录
    sun019
        3
    sun019  
       Mar 17, 2014
    如果太为难sql 还是用程序吧
    xiaokai
        4
    xiaokai  
       Mar 17, 2014
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   6324 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 02:39 · PVG 10:39 · LAX 19:39 · JFK 22:39
    ♥ Do have faith in what you're doing.