With unlang I achive the following: Check, whether a special VLAN exists on a switch and if so, assign it. This works with the construct below. if ("%{sqlquery:SELECT value from radcheck where ( attribute='SIE-VLAN1' != '' and username='%{User-Name}') and value in (select vlan from vlan where nasname= '%{NAS-IP-Address}' ) }"!='') { update reply { Tunnel-Private-Group-ID ="%{sqlquery:SELECT value from radcheck where ( attribute='SIE-VLAN1' != '' and username='%{User-Name}') and value in (select vlan from vlan where nasname= '%{NAS-IP-Address}' )}" Tunnel-Medium-Type = IEEE-802 Tunnel-Type = VLAN } } To reduce sql queries I want to avoid the second. Can I store the result of the first query and use the value to assign Tunnel-Private-Group-ID? Thanks Norbert Wegener