Nq1l query Question

hi
I do not understand English well and use translator

ex
user bucket key type "00f67d3a-15f3-4ef7-9a5e-b04009719806
game bucket key type "00f67d3a-15f3-4ef7-9a5e-b04009719806_XXX

I want to match the user key to the game key

how to make query

example
not working code
select * from game where exists(select meta().id || ‘_XXX’ from user where xxx = ‘xxx’)

try this N1QL:


SELECT u.*,g.* FROM user u 
  JOIN game g 
 ON KEYS meta(u).id || "_XXX" 

2 Likes

atom_yang thank you very much

one more Question
how to update query

example
not working code
update 'game’
set xxx = true
where meta().id IN (
SELECT meta(id)g.* FROM user u
JOIN game g
ON KEYS meta(u).id || "_XXX"
where u.xxx = ‘xxxx’
)

Search results only update

try this N1QL:

update `game`
set xxx = true
where meta().id IN (
SELECT RAW meta(g).id FROM user u 
JOIN game g 
ON KEYS meta(u).id || "_XXX"
where u.xxx = 'xxxx'
)

There is a easy way to update doc :


update `game`
set xxx = true
USE KEYS ['xxxx' || "_XXXX"]

2 Likes

atrom_yang thank you very much
have a nice day