![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据库
你小子在干嘛
这个作者很懒,什么都没留下…
展开
-
like模糊匹配实现精确查询
SELECT * FROM 表名 where FIND_IN_SET(传入的数据,"字段名")原创 2021-12-27 17:20:50 · 820 阅读 · 1 评论 -
case..when用法
适用于一个字段有多个值类型:比如性别这个字段,有1和0分别代表男女 case,when的解析 当user_sex这个字段中的值为1时,转换成男 当user_sex这个字段中的值为0时,转换成女 当user_sex这个字段中的值为其它值的时候,转换成人妖 select user_id,user_name, (case user_sex when '1' then '男' when '2' then '女' else '人妖' end ) user_sex from user_table; ...原创 2021-09-09 17:34:47 · 246 阅读 · 0 评论 -
后台数据统计涉及到周,月,日的统计
-- 查询08月份的数据 select * from epg_itvb_order_detail where date_format(o_date,'%Y%m')='202108' -- 多定义一个字段返回 -- 查询第34周的数据 select * from epg_itvb_order_detail where date_format(o_date,'%Y%u')='202134' --周月主要就是 %m 和 %n的区别 -- 将数据库中符合要求的数据按照周的形式进行统计 select id..原创 2021-09-09 17:41:05 · 467 阅读 · 0 评论 -
获取时间段内的周列表,在本年中的第几周
package test; import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.GregorianCalendar; public class DateTest{ public static void main(String[] args) throws ...原创 2021-09-14 10:57:26 · 186 阅读 · 0 评论 -
查询今天,昨天,本周,上周,本月,上月的数据
select * from tj where to_days(now()) = to_days(tjsj) 查询今天的数据 select SUM(recommend_uv) as recommend_uv from epg_itvb_recommend_cv_uv where to_days(now()) = to_days(re_date) select * from tj where to_days(now()) - to_days(tjsj) = 1 计算昨天的数据 select SUM.原创 2021-09-17 16:36:10 · 77 阅读 · 0 评论 -
数据库中时间有时分秒的查询优化
DATE_FORMAT(cross_time,'%Y-%m-%d') >= DATE_FORMAT(#startTime#,'%Y-%m-%d') 可以优化对于数据库时间中有时分秒的查询 3.1: md文件的sql编写 SELECT @pageTag(){ a.* @} FROM cc_car_pass a WHERE a.isdelete = 0 @if(!isEmpty(entranceNa.原创 2021-09-28 10:01:35 · 213 阅读 · 0 评论 -
inner join 和 left join的区别
inner join 和left join 的区别 A left join B on A.id = B.outId and B.isdelete = 0 ... 是以左边A为主,返回符合关联条件的数据,将B表数据向A表加,on 后 面也可以加条件用以筛选B表的数据 A inner join B on A.id = B.outId and .. inner join 是返回符合筛选条件的数据, ...原创 2021-10-14 11:01:37 · 76 阅读 · 0 评论