mysql中where条件判断语句怎么写_mysql where条件中的判断语句

mysql where条件中的判断语句

AND CASE 1 WHEN "Y"=(SELECT is_open from category as oca where oca.category_id=#{categoryId,jdbcType=VARCHAR})

THEN (cat.category_id = #{categoryId,jdbcType=VARCHAR} OR cat.parent_id = #{categoryId,jdbcType=VARCHAR})

ELSE (cat.category_id = #{categoryId,jdbcType=VARCHAR})

END

mybatis的配置文件:

SELECT c.course_id AS courseId, c.category_id AS categoryId, c.school_id AS schoolId,

c.course_type AS courseType, c.title, c.subtitle,c.summary, c.keywords, c.objectives, c.audiences, c.requirements,

c.cover_image AS coverImage, c.promo_video_id AS promoVideoId, c.promo_video_url AS promoVideoUrl,

c.privacy, c.passwd, c.is_free AS isFree,c. price, c.validity, c.user_id AS userId, c.status,

c.is_recommended AS isRecommended, c.date_recommended AS dateRecommended,c.is_recommended_cetagory AS isRecommendedCetagory,

c.ce_date_recommended AS ceDateRecommended, c.index_order AS indexOrder,c.special_order AS specialOrder, c.date_added AS dateAdded, c.last_modified AS lastModified,

c.published_start_millis AS publishedStartMillis, c.published_end_millis AS publishedEndMillis, c.duration,

u.nickname, u.avatar, cat.name As categoryName

FROM course AS c

LEFT JOIN user AS u ON(c.user_id = u.user_id)

LEFT JOIN category AS cat ON(cat.category_id = c.category_id)

WHERE c.school_id="wxj"

AND CASE 1 WHEN "Y"=(SELECT is_open from category as oca where oca.category_id=#{categoryId,jdbcType=VARCHAR})

THEN (cat.category_id = #{categoryId,jdbcType=VARCHAR} OR cat.parent_id = #{categoryId,jdbcType=VARCHAR})

ELSE (cat.category_id = #{categoryId,jdbcType=VARCHAR})

END

AND c.course_type=#{courseType,jdbcType=VARCHAR}

AND c.published_start_millis <= ${currTimeMillis} AND c.published_end_millis >= ${currTimeMillis}

]]>

ORDER BY ${orderByClause}

LIMIT ${limitClause}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值