union query in automatic lookup not working

I need to write query in automatic field ‘text’ lookup like this :
select ename from
(select code, ename from tablex
union all
select ‘00’ as code, ‘Admin’ as ename) A
where code =’{field}’
order by ename

but it does not show any result in sc 7.01.021, what did I do wrong here?

hi, do you mean the lookup of the fields that to replace with db values? ok if this is the case, then don’t use automatic lookup for a query

to use a query like the one wrote, try with macros in events, then use your the outcome variables wherever you want

think about automatic lookup like filling for you a “description” of a field from a table instead of its actual dv value id (primary/foreign keys)