我有以下的SQL。如果子查询返回任何内容,我希望能够引入yes / no(真/假)。
SELECT
post.topic_id,
topic.topic_posts,
topic.topic_title,
topic.topic_poster_name,
topic.topic_last_post_id,
topic.topic_start_time,
(SELECT post_time FROM bb_posts WHERE post_id = topic.topic_last_post_id) as last_post_time,
topic.topic_slug,
topic.topic_posts,
`group`.name AS group_name,
`group`.slug AS child_slug,
`parent`.slug AS parent_slug,
(SELECT id FROM table WHERE condition = 1) as isTrue << subquery
FROM bb_posts post
LEFT JOIN bb_topics topic
ON topic.topic_id = post.topic_id
LEFT JOIN bb_forums forum
ON topic.forum_id = forum.forum_id
LEFT JOIN wp_bp_groups_groupmeta groupmeta
ON forum.forum_id = groupmeta.meta_value
LEFT JOIN wp_bp_groups `group`
ON groupmeta.group_id = `group`.id
LEFT JOIN wp_bp_groups `parent`
ON `group`.parent_id = `parent`.id
$conditions
GROUP BY topic_id
ORDER BY $sort_col $dir
LIMIT $offset,$num如果结果返回,我希望子查询返回一个yes。