【发布时间】:2016-06-22 13:01:55
【问题描述】:
我在这里的最后一次 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
【问题讨论】:
-
为什么不使用
$this->db->query("your query")? -
您遇到了哪个错误?请在这里也写下错误,以便我们正确理解问题。
-
@VivekPipaliya 已经完成,错过了子查询的左括号:)
-
@Stefan 尝试查询绑定
标签: php mysql sql codeigniter