Mysql常用命令,增删查改、高性能模糊查询,按时间升、降序,总条数

新增数据:INSERT INTO '数据库名称' set

INSERT INTO active set `keyword` = '1',`img_time` = '2019-07-01'

删除数据:DELETE from '数据库名称'

DELETE from active  where 1 = 1  and `active_id` = '19c61c32bd349896'

详情数据:select * from '数据库名称'

select * from active where 1 = 1  and `active_id` = '1af8bad12c1515b3'

修改数据:update '数据库名称' set

update active set `active_id` = '19c61c32bd349896',`keyword` = '666'

修改某个数据:update '数据库名称' set

update active set `check_status` = '2' where 1 = 1  and `active_id` = '16394ad531f1d6a5';

获取列表数据:select * from '数据库名称' limit

select * from active limit 0, 10;

模糊查询:keyword like '%1%'

select * from active where 1 = 1 and keyword like '%1%'

模糊查询高性能方法:LOCATE('',关键字)

select * from active where 1 = 1 and LOCATE('',keyword) ORDER BY img_time DESC limit 0, 10

按时间排序:ORDER BY

  • asc是指定列按升序排列,desc则是指定列按降序排列。

select * from active where 1 = 1 and keyword like '%%'   ORDER BY img_time DESC limit 0, 10

select * from active where 1 = 1 and keyword like '%%'   ORDER BY img_time ASC limit 0, 10

获取总条数:count(*)

select count(*) as count from active where 1 = 1

 

 

 

你可能感兴趣的:(Myql)