将SQL转换为Codeigniter查询

时间:2016-06-22 13:01:56

标签: php mysql sql codeigniter

我已经从最后的unswer中获得了SQL,但是无法将其转换为CodeIgniter Query,遇到一些错误,有人可以帮我解决这个问题吗?非常感谢!

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

1 个答案:

答案 0 :(得分:1)

使用简单的查询格式。

$this->db->query('YOUR QUERY HERE');