"select ... from ... where i.name = m.code and m.code in (select ref from tmp)"