I've got SQL from my last unswer here, but can't transform this to CodeIgniter Query, get an some errors, does anybody can help me with this? huge thanks!
select topic_tags.slug_tag, t1.post_id, t1.post_url, t1.post_subject
from topic_tags
inner join user_topics on topic_tags.id_topic = user_topics.topic_id
left join
select max(topic_tags.slug_tag) as unique_slug_tag, posts.post_id, posts.post_url, posts.post_subject
from topic_tags
inner join user_topics on topic_tags.id_topic = user_topics.topic_id
inner join tags on tags.tag_slug = topic_tags.slug_tag
inner join posts_tags on tags.id_tag = posts_tags.tagid
inner join posts posts_tags.postid = posts.post_id AND posts_tags.creator_id =$u
where topic_tags.id_topic = $i
group by posts.post_id, posts.post_url, posts.post_subject) t1 on topic_tags.slug_tag = t1.unique_slug_tag
where topic_tags.id_topic = $i