mysql的一些语句


 

右补0:select RPAD(id,8,'0') as pad from tablename; 

左补0:select LPAD(id,8,'0') as pad from tablename;

字符串连接:update tableName set title=CONCAT(‘abc’,title,’def’) WHERE id=1

字符串截取【一】:select left(title,50) from tablename

字符串截取【二】:

select substring(title,5) as newTitle from tablename

select substring(title,5,100) as newTitle from tablename

字符串截取【三】:select substring_index(title,'@') as newTitle from tablename