标签:
## mysql 截取函数 left(),right(),substring(),substring_index()
SELECT LEFT(‘www.baidu.com‘,3); # www
SELECT RIGHT(‘www.baidu.com‘,3); # com
SELECT SUBSTRING(‘www.baidu.com‘,3); # w.baidu.com
SELECT SUBSTRING(‘www.baidu.com‘,-3); # com
SELECT SUBSTRING(‘www.baidu.com‘,5,5); # baidu
SELECT SUBSTRING_INDEX(‘www.baidu.com‘,‘.‘,1); # www
SELECT SUBSTRING_INDEX(‘www.baidu.com‘,‘.‘,-2); # baidu.com
#demo between and 是包含等于号的,
SELECT t.`order_no`,LEFT(t.`rent_time`,8),LEFT(t.`revert_time`,8) FROM trans t WHERE order_no=‘491542211061‘
AND LEFT(t.`rent_time`,8) BETWEEN 20160115 AND 20160116;
# mysql设置更新列时间自动修改时间
`update_time` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT ‘更新时间‘,
标签:
原文地址:http://www.cnblogs.com/simpledev/p/5353191.html