MySQL补充sql

筛选出相同活动id中的时间最大的数据

SELECT *,MAX(am.last_update_time) FROM activity_media am GROUP BY am.activity_uuid

数据库添加字段sql

alter table <数据表名> add <字段名> <字段类型> null comment 'xxx';
例如:alter table dev_facility add old_status varchar(50) null comment '旧的运行状态';

sql两个时间对比大小,如果TIMESTAMPDIFF()中的时间字段为null则TIMESTAMPDIFF()函数段不生效,但剩下sql依然生效,两条sql查询出来的条数相等

select * from order_info WHERE consumer_time is not null and TIMESTAMPDIFF(day,consumer_time, now()) >= 10

select * from order_info WHERE TIMESTAMPDIFF(day,consumer_time, now()) >= 10

 Mybatis 插入数据后返回自增主键ID

https://blog.51cto.com/928343994/5138192

in、exists、all、any、some用法与区别

https://blog.csdn.net/tjuyanming/article/details/77015427
https://blog.csdn.net/qq_35499112/article/details/85763533
https://blog.csdn.net/weixin_41926488/article/details/80317225?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-80317225-blog-77015427.pc_relevant_scanpaymentv1&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-1-80317225-blog-77015427.pc_relevant_scanpaymentv1&utm_relevant_index=1

时间排序

desc descend (降序)
asc ascend( 升序)

select * from   user where Putout=true order by time desc //按最新时间排序
select * from user where Putout=true order by time asc    //反之

查询出来的数据按字典序排序

模糊查询 LIKE CONCAT()的使用

https://blog.csdn.net/weixin_45082766/article/details/116998300

查询两个表不同的数据

select * from B where (select count(1) from A where A.ID = B.ID) = 0

查询两个表相同的数据可以用union all

select * from a 
union all 
select * from b

 表中添加字段的sql

http://c.biancheng.net/view/7201.html

<![CDATA[ ]]>的简单使用

<selectKey>标签的作用

 

posted on 2022-05-11 14:00  飘来荡去evo  阅读(18)  评论(0编辑  收藏  举报

导航