I have one column which has comma separated values(ids). I need to change corresponding values to them. I need MySQL function for replacing.
Here my table1.
id name
-------------------
1 Lara
2 Smith
3 Antony
4 Ken
Here my table2
id friends
---------------------
1 2,3
2 1,2
3 1,3
4 1,4,3,2
My MySQL function (get_names) should return names with comma separated instead of name'ids when I querying my table2.
ex.
when I call like this
select get_names('1,2,3,4','Lara,Smith,Antony,Ken','3,1');
it should return Antony,Lara
Here
My
1st parameter is - total user ids with comma separated order
2nd parameter is - total user name with comma separated order (same order like user ids)
3rd parameter is - any no. of user ids with comma separated any order
Please help me.