How to join the same bucket?

n1ql
#1

I have documents in the same bucket with two doc.type.
How can I JOIN them using N1QL?
Like:

Select * from bucket as a where a.type = 'typeA'
JOIN 
select * from bucket as b where b.type = "typeB"
ON a.TypeBId = b.Id

Thanks

#2

Hello,

You can use:

Please see the documentation and examples for more details.

#3

Dear @geraldss, default condition JOIN BY “Id”? If i want JOIN by other field, ex: name, email…, can N1ql do?
Thank you.

#4

Hi @Sonrobby,

JOINs in N1QL do require that one document contain or compute the id / key of the other document. This is necessary for performance reasons.