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\[ \< ]>

<

相关推荐
奇牙coding27 分钟前
Codex CLI 升级后多文件编辑静默失效:config.yaml 枚举变更排查与修复指南
java·前端·javascript·ai
小羊没烦恼!34 分钟前
Ajax与JSON的一些总结
android·java·前端·数据库·mysql·算法·okhttp
Lhappy嘻嘻40 分钟前
读懂 JVM:内存模型、类加载机制、分代回收
java·开发语言·jvm
黄俊懿41 分钟前
【架构师从入门到进阶】第六章:服务集群优化——第八节:线程数公式
java·服务器·数据库·分布式·性能优化·架构·系统架构
Rain的Java大神之路1 小时前
别再死磕 MySQL 了:向量数据库与 RAG 生产落地实录(Java 工程师专场)
java·后端·面试
七夜zippoe1 小时前
Spring AI 是什么?Java 工程师的 AI 开发第一站
java·人工智能·spring·ai·开发
geovindu1 小时前
sql: JSON and XML Data Handling in SQL using mysql 9.0
数据库·sql·mysql·数据库开发
是真的小外套1 小时前
2023年软考中级信息安全工程师|选择题考点+5道案例分析真题解析(含答案)
java·服务器·网络
Mortalbreeze1 小时前
MySQL 基础篇(九):从 B+ 树到索引优化,全面理解 MySQL 索引
数据库·mysql
会编程的吕洞宾1 小时前
Spring AI 2.0 结构化输出实战:让大模型返回精准 JSON 不再“抽风“,准确率从 78% 拉到 99%
java·后端