当前位置:网站首页>mysql写的代码数据 增删查改等等

mysql写的代码数据 增删查改等等

2022-06-24 07:06:00 隐密修罗

新增数据: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
————————————————
版权声明:本文为CSDN博主「时间飞逝子非鱼」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/lgysjfs/article/details/100077636

原网站

版权声明
本文为[隐密修罗]所创,转载请带上原文链接,感谢
https://blog.csdn.net/qq_18390335/article/details/106062639