mysqlcawhenlike_mysql中cawhen用法

更新时间:2023-06-19 08:02:48 阅读: 评论:0

mysqlcawhenlike_mysql中cawhen⽤法
需求:需要在查询出的字段中,判断这个某个字段是否为null,并指定想要的值,
SELECT
temp.gId
id,temp.`name`,temp.point,temp.give_ur_proportion,temp.sales_ver_img,temp.limit_num,temp.price,temp.show_sale_ is_promotionFROM(SELECTallgoods.gId,
allgoods.`name`,
allgoods.sale_num,
allgoods.point,
爱情签名allgoods.give_ur_proportion,
allgoods.sales_price,
allgoods.productId,pi.limit_num,pi.price,pi.show_sale_price,CASE
WHEN pi.price IS NULL THEN
FALSE
ELSE
TRUEEND ASisPromotionFROM(SELECTgood.id gId,
good.`name`,
good.sale_num,
good.point,
good.give_ur_proportion,
手抄报元旦
produc.sales_price,
produc.id productIdFROM(SELECT
*
FROMgoods goodstempWHEREgoodstemp.is_del=FALSEAND goodstemp.check_status = 'configed'
AND goodstemp.category_id = 174976742484877312) goodLEFT JOIN(SELECT
*
FROMproduct p2WHEREp2.is_del=FALSEAND p2.is_putaway =TRUEAND p2.is_show =TRUE
) producON good.id =ds_idWHEREgood.ds_id
想长高吃什么钙片) allgoodsLEFT JOIN(SELECT
*
FROMpromotion promWHEREprom.is_del=FALSEAND TO_DAYS(NOW()) >=TO_DAYS(prom.start_date)AND
TO_DAYS(NOW()) <=TO_d_date)AND prom.publish_status = 'published') promotiontempON allgoods.gId
=ds_idLEFT JOIN promotion_item pi ON promotiontemp.id = pi.promotion_id
)temp
ORDER BY
temp.isPromotion DESC
结果:
当你的表⽰myisam时:
SELECT * FROM tbl -- this will do a "table scan". If the table has never had any DELETEs/REPLACEs/UPDATEs, the records will happen to be in the inrtion order, hence what you obrved.
弹性退休⼤致意思为,⼀个myisam引擎表在没有任何的删除,修改操作下,执⾏ lect 不带order by,那么会按照插⼊顺序进⾏排序。
楚怀王熊心>羚羊木雕原文If you had done the same statement with an InnoDB table, they would have been delivered in PRIMARY KEY order, not INSERT order. Again, this is an artifact of the underlying implementation, not something to depend on.
对于innodb引擎表来说,在相同的情况下,lect 不带order by,会根据主键来排序,从⼩到⼤世界最大内陆国
>考研村

本文发布于:2023-06-19 08:02:48,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1045295.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:排序   删除   查询
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图