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
FelixXie
V2EX  ›  MongoDB

请教个问题,这个 sql 语句是否可以在 mongoDb 中实现?

  •  
  •   FelixXie · Mar 7, 2017 · 3900 views
    This topic created in 3348 days ago, the information mentioned may be changed or developed.
    SELECT *,
    ( IF(LOCATE('腾讯', title), 4, 0) + IF(LOCATE('腾讯', content), 2, 0) + IF(LOCATE('逆市', title), 4, 0) + IF(LOCATE('逆市', content), 2, 0) ) AS score
    FROM s_data
    WHERE ( (title LIKE '%腾讯%') OR (content LIKE '%腾讯%') OR (title LIKE '%逆市%') OR (content LIKE '%逆市%') )
    ORDER BY score DESC, created_at Desc LIMIT 10
    1 replies    2017-03-31 15:59:26 +08:00
    li35619081
        1
    li35619081  
       Mar 31, 2017
    可是 可以 比较复杂而已啦。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1146 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 23:07 · PVG 07:07 · LAX 16:07 · JFK 19:07
    ♥ Do have faith in what you're doing.