Int -> varcher
将Int 转为varchar可以用 concat()
函数,比如 concat(8,’0′)
得到字符串 ’80′。
delete from core_channel;
drop procedure if exists insert_channel;
delimiter //
CREATE procedure insert_channel()
wholeblock:BEGIN
declare str VARCHAR(255) default '';
declare x INT default 0;
SET x = 1;
WHILE x <= 10 DO
insert into core_channel (name) values (CONCAT("name",x));
SET x = x + 1;
END WHILE;
select str;
END//
call insert_channel ();
Varcher -> Int
将 varchar 转为 Int 用 cast(a as signed)
,a为varchar类型的字符串。
FEATURED TAGS
algorithm
algorithmproblem
architecturalpattern
architecture
aws
c#
cachesystem
codis
compile
concurrentcontrol
database
dataformat
datastructure
debug
design
designpattern
distributedsystem
django
docker
domain
engineering
freebsd
git
golang
grafana
hackintosh
hadoop
hardware
hexo
http
hugo
ios
iot
java
javaee
javascript
kafka
kubernetes
linux
linuxcommand
linuxio
lock
macos
markdown
microservices
mysql
nas
network
networkprogramming
nginx
node.js
npm
oop
openwrt
operatingsystem
padavan
performance
programming
prometheus
protobuf
python
redis
router
security
shell
software testing
spring
sql
systemdesign
truenas
ubuntu
vmware
vpn
windows
wmware
wordpress
xml
zookeeper