如何将给定的多重连接查询转换为 ZendFrame 工作查询
SELECT
`blg`.`id` ,
`blg`.`heading` ,
`blg`.`description` ,
`cat`.`name` AS `categoryname` ,
`mem`.`firstname` AS `user` ,
( SELECT COUNT( * ) FROM blog_comments WHERE blog_comments.status = '1' AND blog_comments.blogid = blg.id) AS `commentcount`
FROM `blogs` AS `blg`
INNER JOIN `blog_category` AS `cat` ON blg.category = cat.id
INNER JOIN `members_member` AS `mem` ON blg.user = mem.id
LEFT JOIN `blog_comments` AS `cmt` ON blg.id = cmt.blogid
WHERE ( blg.status = '1' )
GROUP BY blg.id ORDER BY `blg`.`id` ASC
SELECT
`blg`.`id` ,
`blg`.`heading` ,
`blg`.`description` ,
`cat`.`name` AS `categoryname` ,
`mem`.`firstname` AS `user` ,
( SELECT COUNT( * ) FROM blog_comments WHERE blog_comments.status = '1' AND blog_comments.blogid = blg.id) AS `commentcount`
FROM `blogs` AS `blg`
INNER JOIN `blog_category` AS `cat` ON blg.category = cat.id
INNER JOIN `members_member` AS `mem` ON blg.user = mem.id
LEFT JOIN `blog_comments` AS `cmt` ON blg.id = cmt.blogid
WHERE ( blg.status = '1' )
GROUP BY blg.id ORDER BY `blg`.`id` ASC
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
像这样的东西怎么样:
输出:
What about something like this:
Output: