函数:是指一段可以直接被另一段程序调用的程序或代码
代码:
select lpad('01',5,'-');/*lpad:字符串左填充 ---01 */select rpad('01',5,'-');/*rpad:字符串右填充 01--- */
select trim(' hello mysql ');/*trim:去除头部和尾部的空格 */
select substring('hello mysql',1,5);/*substring:索引从1开始,截取字符串 */
select * from emp;
insert into emp (id, workId, name, sex, age, idcard, ertrydate) VALUES (1,'01','张三','男',16,'2002','2002-12-03'),
(2,'02','李四','女',17,'2003','2002-11-04'),
(3,'03','王五','男',18,'2004','2002-10-05'),
(4,'04','老六','男',19,'2005','2002-09-06'),
(5,'05','张七七','女',20,'2006','2002-08-07'),
(6,'06','老八','男',21,'2007','2002-07-08'),
(7,'07','小九','男',22,'2008','2002-06-09'),
(8,'08','王十','女',23,'2009','2002-05-10');
update emp set workId=lpad(workId,5,'0');/*将员工工号改为五位,不足五位的在左边填充0 */