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

<

相关推荐
敲上瘾28 分钟前
MySQL数据库表的约束
linux·数据库·sql·mysql·数据库开发·数据库架构·数据库系统
努力的搬砖人.30 分钟前
SQLite 转换为 MySQL 数据库
数据库·mysql·sqlite
2301_803297751 小时前
Shell编程值正则表达式和文本处理器
数据库·mysql·正则表达式
.生产的驴1 小时前
Maven 公司内部私服中央仓库搭建 局域网仓库 资源共享 依赖包构建共享
java·maven
Auc241 小时前
OJ判题系统第6期之判题逻辑开发——设计思路、实现步骤、代码实现(策略模式)
java·开发语言·docker·容器·策略模式
老李不敲代码1 小时前
榕壹云搭子系统技术解析:基于Spring Boot+MySQL+UniApp的同城社交平台开发实践
spring boot·mysql·微信小程序·uni-app·软件需求
快乐肚皮1 小时前
深入解析Docker:核心架构与最佳实践
java·运维·docker·容器
zhou1851 小时前
MySQL保姆级安装教程(附资源包+5分钟极速配置+环境变量调试技巧)
java·python·mysql·php
小雅痞2 小时前
[Java][Leetcode middle] 55. 跳跃游戏
java·leetcode
com未来2 小时前
使用 NSSM 安装 Tomcat 11.0.6 为 Windows 服务
java·windows·tomcat