Skip to content

Instantly share code, notes, and snippets.

@kylefelipe
Last active June 14, 2022 19:20
Show Gist options
  • Save kylefelipe/b3b93611cc999ad3a001e221e59a6e2b to your computer and use it in GitHub Desktop.
Save kylefelipe/b3b93611cc999ad3a001e221e59a6e2b to your computer and use it in GitHub Desktop.
Selecting features from table A using table B
-- Expression to be used at SELECT BY EXPRESSION AT LAYER A
array_contains( -- This will return true if the array contains the value
aggregate( -- will aggregate all values from target in to a string, using semicolons as concatenator
layer:='<table_b>', -- Target table containing the values, replace <table_b> whith your table name
aggregate:='array_agg',
expression:=to_string("<field_from_table_b>"), -- Field from table_b containing the values
),
"<field_table_a>") -- Field from table a with values to compare, replace <field_table_a> with your field name
@kylefelipe
Copy link
Author

Thx @pigreco for the last revision tip....
I always forget the 'array_agg'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment