gpt4 book ai didi

mysql - 按字符长度排序但不想过滤

转载 作者:行者123 更新时间:2023-12-01 00:39:33 28 4
gpt4 key购买 nike

想要对评论长度 <= 250 和 >= 50 的评论进行排序

所有短评论或长评论都应该放在最后..目前我必须过滤它们...但这不是我想要的

当前查询

select
c.id,
c.name,
DATE_FORMAT(c.created,'%d %b %Y') as date_new,
r.ratings,
c.comments,
ROUND((r.ratings_sum / r.ratings_qty),1) as total_rating
from
commentsAS c , rating AS r , id_script i
where
c.pid = i.sub_cat_id
AND i.cat_id = 118
AND r.reviewid = c.id
AND c.published = '1'
AND LENGTH(c.comments) <= 250
AND LENGTH(c.comments) >= 50
ORDER BY c.created DESC

我不想用下面的过滤它们

AND LENGTH(c.comments) <= 250
AND LENGTH(c.comments) >= 50

最佳答案

ORDER BY
CASE
WHEN LENGTH(C.comments) > 250 OR LENGTH(C.comments) < 50 THEN 1
ELSE 0
END

关于mysql - 按字符长度排序但不想过滤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36752090/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com