Je ne sais pas si cela va fonctionner dans mySQL mais SqlServer vous pouvez créer une fonction:
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
puis appelez simplement:
select id, nos, dbo.replaceIdsWithValues(nos) from t1
qui en supposant que votre structure de tables:
create table t1 (id int, nos varchar(50))
create table t2 (id int, theValues varchar(50))
Vous pouvez tester l'exemple complet
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
Très difficile à lire, mais voulez-vous vraiment dire que dans le tableau 1 il y a trois lignes. Dans le premier a la valeur de varchar "12, 13, 14"? –