mysql的常用函数

1、保留两位小数

Round(rent_income/10000,2) rent_income,

2、where 条件

where m1.is_deleted = 0

-- 物料编号/名称/入库单号/入库仓库

and (

m3.material_no like CONCAT('%','1','%')

or m3.material_name like CONCAT('%','1','%')

or m1.stock_in_single_no like CONCAT('%','1','%')

or m4.warehouse_name like CONCAT('%','1','%')

)

and m1.project_id in ( 322,323 )

and m1.audit_status = 1003

and date_format(m1.stock_in_time, '%Y-%m-%d') > '2022-04-29'

and date_format(m1.stock_in_time, '%Y-%m-%d') < '2022-08-29'

3、日期相减

DATEDIFF(cont_real_end_date,cont_begin_date)

4、最大值

select max(submit_time) from asset_operating_fixed

where is_deleted = 0 and project_id = pm.id

and date_format( submit_time, '%Y-%m' ) <= date_format( NOW(), '%Y-%m' )

5、if语句

IF(mom.month_profit = NULL,NULL,(hb.month_profit - mom.month_profit)/mom.month_profit) as month_profit_mom,

GROUP BY m1.id

6、指定数据库

-- and table_schema = 'amp_xinjin'

7、查询表的所有字段名称 各种拼接

-- column_comment COLUMN_NAME

-- "id":"自增id",

-- select GROUP_CONCAT('"' ,COLUMN_NAME ,'":"',column_comment,'"') from information_schema.COLUMNS

-- where table_name = 'project_format_records' ;

-- "id","project_id",

-- select GROUP_CONCAT('"',COLUMN_NAME,'"' ) result from information_schema.COLUMNS

-- where table_name = 'project_format_records' ;

-- id,project_id,

select GROUP_CONCAT('' ,COLUMN_NAME ,'') from information_schema.COLUMNS

where table_name = 'project_format_records' ;

8、xml里面的小于号
<![CDATA[ < ]]>

<

相关推荐
海边的椰子树6 分钟前
非常方便的MySQL迁移数据ClickHouse工具
数据库·mysql·clickhouse·迁移
ryy102550631918 分钟前
Springboot+Mysql 图书管理系统【源码+sql】
spring boot·sql·mysql
悟空码字24 分钟前
无缝集成指南,SpringBoot三步接入华为云短信服务
java·springboot·编程技术·后端开发·华为云短信
航Hang*29 分钟前
第3章:复习篇——第3节:数据查询与统计---题库
数据库·笔记·sql·学习·mysql·期末·复习
廋到被风吹走30 分钟前
【数据库】【MySQL】事务隔离深度解析:MVCC 实现与幻读解决机制
android·数据库·mysql
E_ICEBLUE30 分钟前
【2026 最新教程】Java 自动化提取 PDF 表格:从文本到 Excel/CSV 的全场景实现
java·pdf·自动化
C雨后彩虹31 分钟前
无向图染色
java·数据结构·算法·华为·面试
J_HelloWorld33 分钟前
缺页中断:Java高性能存储的隐形推手
java·缺页中断
一代明君Kevin学长37 分钟前
记录一个上手即用的Spring全局返回值&异常处理框架
java·网络·python·spring
Star Learning Python39 分钟前
MySQL面试的基础知识
数据库·sql