MySql常用函数

1. replace(column,'old','new') 把column列中旧的数据替换成新的数据

update product set description=replace(description,'kindeditor','')

 

 2. LEFT(column, num) 查询column中Num个字节的字符串,用来查询子字符串

SELECT LEFT(NAME,2)  from city

 

 3. 查询当天数据 to_days()

mysql> select count(1) from flow_shipment where status=2 and  to_days(create_time)=to_days(now());

 

4. 查询一天前数据 date_sub()

mysql> select count(1) from flow_shipment where status=2 and  create_time>DATE_SUB(CURDATE(), INTERVAL 1 DAY);

 

5. 查询30分钟前的数据 

select Id,OrderId,Status from OrderHistory where UpdateTime<(CURRENT_TIMESTAMP - INTERVAL 30 MINUTE)

 

 

你可能感兴趣的:(mysql)