MongoDB and Sub-query

23 views
Skip to first unread message

cch...@gmail.com

unread,
May 22, 2017, 7:39:48 AM5/22/17
to SlamData-User
Hi, I'm having a query with a sub-query which selects the next relevant item of the main query in the same collection but I always get an empty result here

SELECT 
id,
Time AS Time1
(
SELECT
sub.Time
FROM A AS sub
WHERE 
sub.value="Event" AND
sub.Time2 > main.Time1 AND
sub.state BETWEEN 0 AND 2
ORDER BY sub.Time
LIMIT 1
    ) AS Time2
FROM A AS main
WHERE 
    value="Event" AND
    state BETWEEN 3 AND 6
ORDER BY Time1 ASC

The sub-query alone runs perfectly fine. Wondering if there's any constraint running a sub-query or what else could be wrong?
Reply all
Reply to author
Forward
0 new messages