Many to many relationship using N1ql couchbase query

utpal poulik

User bucket data structure

Docid : "user123456"
{
Name: utpal,
Phone: 98222333,
Age:30,
addressids:["add_123","add_1234"]

}

Address bucket

Docid : add_123
{
Name: behala,
Location: kolkata
}

Docid : add_123
{
Name: behala1,
Location: kolkata1
}

I want to Desire results

[{
Name: utpal,
Phone: 98222333,
Age:30,

addressids:["add_123","add_1234"],

address:[
{
Name: behala,
Location: kolkata
},
{
Name: behala1,
Location: kolkata1
}
]

Any one help me how to write a N1ql query for that result

vsr
INSERT INTO default VALUES("user123456" { "Name": "utpal", "Phone": "98222333", "Age":30, "addressids":["add_123","add_1234"], "type":"user"});
INSERT INTO default VALUES("add_123", { "Name": "behala", "Location": "kolkata" });
INSERT INTO default VALUES("add_1234", { "Name": "behala4", "Location": "kolkata4" });


SELECT u.*, address
FROM default AS u
LET address = (SELECT RAW a FROM default AS a USE KEYS u.addressids)
WHERE u.type = "user";

OR

SELECT u.*, address
FROM default AS u
NEST default AS address ON u.addressids
WHERE u.type = "user";

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Using IN clause in couchbase N1Ql @query or use findAll(keys) from couchbase JPA

From Dev

Couchbase N1QL query aggregation

From Dev

Couchbase N1QL query with dictionary

From Dev

Querying Couchbase using N1QL

From Dev

Query many to many relationship with DetachedCriteria

From Dev

how to query a many to many relationship?

From Dev

eloquent: query many to many relationship

From Dev

Query in many to many relationship - mySQL

From Dev

Complex query in a many to many relationship

From Dev

Laravel query on Many to Many relationship

From Dev

JPQL query with many to many relationship

From Dev

Async N1QL couchbase query using Twisted API for Python SDK

From Dev

Query on a many-to-many relationship using Doctrine with Symfony2

From Dev

Sequelize - Query with Many-to-Many relationship using where and limit

From Dev

How best to query a 1:many:many relationship efficiently using the SQLAlchemy ORM?

From Dev

Trouble with N1QL query and index in Couchbase

From Dev

Couchbase parameterized N1QL query IN statement

From Dev

Add count to N1QL query result in Couchbase

From Java

Couchbase java N1QL DSL query statement with IN expression

From

golang Couchbase n1ql query pass params to?

From Java

How to write Couchbase N1QL query in spring data?

From Dev

Why is there a syntax error - at 0 in this Couchbase N1QL query?

From Dev

Couchbase N1QL: index and query on array fields

From Dev

Start with Couchbase N1QL query in xampp

From Dev

Couchbase N1QL Query - Include outer document as parent

From Dev

How to query an one to one to many relationship using TypeORM query builder?

From Dev

Many to Many Relationship - how to query all children

From Dev

HQL query for Many to Many Explict relationship

From Java

JPQL query with many-to-many relationship

Related Related

  1. 1

    Using IN clause in couchbase N1Ql @query or use findAll(keys) from couchbase JPA

  2. 2

    Couchbase N1QL query aggregation

  3. 3

    Couchbase N1QL query with dictionary

  4. 4

    Querying Couchbase using N1QL

  5. 5

    Query many to many relationship with DetachedCriteria

  6. 6

    how to query a many to many relationship?

  7. 7

    eloquent: query many to many relationship

  8. 8

    Query in many to many relationship - mySQL

  9. 9

    Complex query in a many to many relationship

  10. 10

    Laravel query on Many to Many relationship

  11. 11

    JPQL query with many to many relationship

  12. 12

    Async N1QL couchbase query using Twisted API for Python SDK

  13. 13

    Query on a many-to-many relationship using Doctrine with Symfony2

  14. 14

    Sequelize - Query with Many-to-Many relationship using where and limit

  15. 15

    How best to query a 1:many:many relationship efficiently using the SQLAlchemy ORM?

  16. 16

    Trouble with N1QL query and index in Couchbase

  17. 17

    Couchbase parameterized N1QL query IN statement

  18. 18

    Add count to N1QL query result in Couchbase

  19. 19

    Couchbase java N1QL DSL query statement with IN expression

  20. 20

    golang Couchbase n1ql query pass params to?

  21. 21

    How to write Couchbase N1QL query in spring data?

  22. 22

    Why is there a syntax error - at 0 in this Couchbase N1QL query?

  23. 23

    Couchbase N1QL: index and query on array fields

  24. 24

    Start with Couchbase N1QL query in xampp

  25. 25

    Couchbase N1QL Query - Include outer document as parent

  26. 26

    How to query an one to one to many relationship using TypeORM query builder?

  27. 27

    Many to Many Relationship - how to query all children

  28. 28

    HQL query for Many to Many Explict relationship

  29. 29

    JPQL query with many-to-many relationship

HotTag

Archive