select t21.name
from table1 as t1
inner join table2 as t21 on t1.code = t21.code1
where t1.comment like '%1です%'
union
select t22.name
from table1 as t1
inner join table2 as t22 on t1.code = t22.code2
where t1.comment like '%1です%'
union
select
t23.name
from table1 as t1
inner join table2 as t23 on t1.code = t23.code3
where t1.comment like '%1です%'


多分↑で通るけど、もっといい模範解答求む