SELECT LPAD(UserID,5,0) as id FROM tuser t; PS: 附上PHP 后台数字补零方法: echo str_pad(123, 10, "0 ", STR_PAD_LEFT);