Select JOIN existence as boolean

Hello,

Let’s imagine I’ve got something like the follow:

player::1

SELECT player.name, player.age FROM default player
WHERE _type = "player"

This should work. But let’s say I have a document named player::1::is_national_player (its contents doesn’t matter).

Therefore I would like to use the first query, and for each player, I would like to know if he would have that document, returning a boolean.

I’ve tried something like the following, but it doesn’t seem to work. Am I missing something or how can I achieve such result without a separate query?

SELECT player.name, player.age, TOBOOLEAN(is_national_player) AS national_player FROM default player
LEFT JOIN `default` is_national_player ON KEYS "player_" || player.id || "::is_national_player"
WHERE _type = "player"

I’ve tried with and without TOBOOLEAN, and with and without specifying a specific field.

Any ideas?

Something like this.

SELECT player.name, player.age, (is_national_player IS NOT MISSING) AS national_player
FROM default player
LEFT JOIN `default` is_national_player ON KEYS "player_" || player.id || "::is_national_player"
WHERE _type = "player"
1 Like

Thanks a lot, that was exactly what I needed!

1 Like