Не уверен, будет ли это работать в mySQL, но в SqlServer вы можете создать функцию:
create function dbo.replaceIdsWithValues
(
@inIds varchar(50)
)
returns varchar(50)
as
begin
declare @ret as varchar(50)
set @ret = @inIds
select @ret = replace(@ret,cast(id as varchar),theValues) from t2
return @ret
end
, а затем просто позвоните:
select id, nos, dbo.replaceIdsWithValues(nos) from t1
что предполагает вашу структуру таблиц:
create table t1 (id int, nos varchar(50))
create table t2 (id int, theValues varchar(50))
Вы можете проверить полный пример
create table t1 (id int, nos varchar(50))
create table t2 (id int, theValues varchar(50))
insert into t1(id, nos)
select 1, '12,13,14'
union all select 2, '14'
union all select 3, '14,12'
insert into t2(id, theValues)
select 12, 'PHP'
union all select 13, 'JAVA'
union all select 14, 'C++'
select id, nos, dbo.replaceIdsWithValues(nos) from t1