mysql中字符串和整型自动转换的问题

表结构如下 desc info; +-------+-----------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-----------------+------+-----+---------+----------------+ | id | int(8) unsigned | NO | PRI | NULL | auto_increment | | name | varchar(20) | YES | | NULL | | +-------+-----------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec) 执行sql. insert into info values ('', 'xxx'); insert into info values ('', 'yyy'); 查询记录. select * from info; +----+------+ | id | name | +----+------+ | 1 | xxx | | 2 | yyy | +----+------+ 2 rows in set (0.00 sec) 执行下面sql. ...

2020-12-14 · 1 min · 303 words · Liudon

一次惊心动魄的Mysql更新操作

问题描述 # 表结构 MySQL > desc user_packages; +----------------+---------------------+------+-----+---------------------+----------------+ | Field | Type | Null | Key | Default | Extra | +----------------+---------------------+------+-----+---------------------+----------------+ | up_id | bigint(20) unsigned | NO | PRI | NULL | auto_increment | | start_date | date | NO | | NULL | | | end_date | date | NO | | NULL | | | up_created | datetime | NO | MUL | 0000-00-00 00:00:00 | | | up_updated | datetime | NO | | 0000-00-00 00:00:00 | | +----------------+---------------------+------+-----+---------------------+----------------+ 5 rows in set (0.00 sec) MySQL > select * from user_packages limit 5; +-------+------------+------------+ | up_id | start_date | end_date | +-------+------------+------------+ | 185 | 2018-04-01 | 2018-06-30 | | 186 | 2018-04-01 | 2018-06-30 | | 187 | 2018-04-01 | 2018-06-30 | | 188 | 2018-04-01 | 2018-06-30 | | 189 | 2018-04-01 | 2018-06-30 | +-------+------------+------------+ 5 rows in set (0.00 sec) 操作过程 需要更新某条记录的end_date字段,执行sql如下: ...

2020-05-19 · 2 min · 776 words · Liudon