mysql select如果为空_如果在mysql select语句中为空

我有以下的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。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值