mysql 数据库查询和设计
MySQL的FIND_IN_SET()函数
NSERT INTO `test` VALUES (1, 'name', 'daodao,xiaohu,xiaoqin');
INSERT INTO `test` VALUES (2, 'name2', 'xiaohu,daodao,xiaoqin');
INSERT INTO `test` VALUES (3, 'name3', 'xiaoqin,daodao,xiaohu');
test1:sql = select * from `test` where 'daodao' IN (`list`);
得到结果空值.
test2:sql = select * from `test` where FIND_IN_SET('daodao',`list`);
得到三条数据。
查询, 时间戳格式化为日期
【 DATE_FORMAT(from_unixtime(dateline), '%Y-%m-%d %H:%i:%S') 】
select from_unixtime(1560221981);
| 2019-06-11 10:59:41 |
. 对于BTREE这种Mysql默认的索引类型,具有普遍的适用性
. 查找指定库中,哪些表含有特定字段
SELECT DISTINCT TABLE_NAME FROM information_schema.COLUMNS WHERE COLUMN_NAME = 'extend' AND TABLE_SCHEMA='dbname';
Json 格式查询
select count(*) from user where JSON_EXTRACT(extend, '$.sex')=2;