I strongly advise that you fix your current database structure so you are not storing the data in a comma separated list. You should structure your tables similar to the following:
CREATE TABLE posts
(`id` int, `header` varchar(3), `text` varchar(3))
;
CREATE TABLE pics
(`id` int, `name` varchar(3), `url` varchar(3))
;
CREATE TABLE post_pics
(`post_id` int, `pic_id` int)
;
Then you can easily get a result by joining the tables:
select p.id,
p.header,
p.text,
c.name,
c.url
from posts p
inner join post_pics pp
on p.id = pp.post_id
inner join pics c
on pp.pic_id = c.id;
See SQL Fiddle with demo.
If you cannot alter your table, then you should be able to query using FIND_IN_SET
:
select p.id, p.header, p.text, p.pics,
c.id c_id, c.name, c.url
from posts p
inner join pics c
on find_in_set(c.id, p.pics)
See SQL Fiddle with Demo.
Edit, if you want the data displayed as a comma-separated list then you can use GROUP_CONCAT
.
Query 1:
select p.id,
p.header,
p.text,
group_concat(c.name separator ', ') name,
group_concat(c.url separator ', ') url
from posts p
inner join post_pics pp
on p.id = pp.post_id
inner join pics c
on pp.pic_id = c.id
group by p.id, p.header, p.text;
See SQL Fiddle with Demo
Query 2:
select p.id, p.header, p.text, p.pics,
group_concat(c.name separator ', ') name,
group_concat(c.url separator ', ') url
from posts p
inner join pics c
on find_in_set(c.id, p.pics)
group by p.id, p.header, p.text, p.pics;
See SQL Fiddle with Demo