gpt4 book ai didi

mysql - 如何在SQL where 条件中放入If else 语句?

转载 作者:行者123 更新时间:2023-11-29 04:43:15 25 4
gpt4 key购买 nike

我有一个名为 article 的表,其中包含字段 daymonthyeartitle。因此表中文章的日期将是日-月-年,但已以 3 个不同列的形式存储。我需要从表格中获取在给定的 start_dateend_date 之间发表的所有文章的标题。

假设 start_date 也以 3 个变量的形式给出 - sday , smonth , syear

end_date 作为 3 个变量 - eday , emonth , eyear

如何为上述内容编写 mysql 查询?提前致谢。

最佳答案

我假设您的字段是数字。所以你可以使用下面的代码:

select * 
from article
where (year*10000+month*100+day) between (syear*10000+smonth*100+sday) and (eyear*10000+emonth*100+eday)

关于mysql - 如何在SQL where 条件中放入If else 语句?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24103722/

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