Couchbase N1QL join query

前端 未结 1 1811
有刺的猬
有刺的猬 2021-01-07 04:07

need help with a query in Couchbase enviroment.

Both document 1 and document 2 is in the same bucket.

First the query will get the document message1 using this

相关标签:
1条回答
  • 2021-01-07 04:31

    Assuming that the name of Document2 is based on the uid of Document1, that is, "user1" is based on uid=1, you can do the following:

    SELECT d1.uid, d1.message, d1.sent_by, d2.username
    FROM mybucket d1 USE KEYS "message1"
    JOIN mybucket d2 ON KEYS "user" || d1.uid;
    
    0 讨论(0)
提交回复
热议问题