Filter joined

Hi everyone,

i’m trying to add a filter join in my custom data but I can’t.
Here is my sql request :

select 
users.registration_number AS `Num agent`,
entities.name `Direction`,
uservpns.identifiantvpnfield

FROM glpi_plugin_fields_uservpns AS uservpns

LEFT JOIN glpi_users AS users ON uservpns.items_id=users.id
LEFT JOIN glpi_profiles_users AS profiles_users ON (uservpns.items_id=profiles_users.users_id AND profiles_users.entities_id NOT IN (1,39) AND profiles_users.is_dynamic=1)
LEFT JOIN glpi_entities AS entities ON (profiles_users.entities_id = entities.id)

WHERE uservpns.compteactiffield=1
AND entities.name IN {{direction}}

Here is the error :
You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'glpi_entities.nameIN ('IT')' at line 13

In my Where clause, I’ve tried

WHERE uservpns.compteactiffield=1
AND {{direction}}

But I get this error :
Unknown column 'glpi_entities.name' in 'where clause'

Could you help me please ?

Hi @Livier
You cannot use table aliases when using Field Filters:
https://www.metabase.com/blog/field-filters/index.html

Thank you very much for your help