关键字最好选择大写,可提高阅读性,和维护更直观
一般使用navcat可视化化工具创建表,后增删改查
创建键并进入数据库
CREATE DATABASE 'Segi' IF NOT EXISTS
USE segi
新建一个表,并声明列
CREATE TABLE IF NOT EXISTS `test` (
`id` int(11) NOT NULL AUTO_INCREMENT COMMENT `文章的id`,
`create_time` datetime NOT NULL COMMENT '创建的时间',
`title` varchar(255) NOT NULL COMMENT '标题名称',
`view_number` int(11) NOT NULL DEFAULT '0' COMMENT '浏览次数',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='文章表' AUTO_INCREMENT=28 ;
增加数据
INSERT INTO test
(create_time
, title
, view_number
) values
(‘2018-12-19 16:39:39‘, ‘你好世界‘, 5),
(‘2018-12-19 16:39:39‘, ‘你好世界2‘, 5);
删除数据
修改数据
查找分页
let result = {
pageinator: {
pageLength,
pageNo
}
}
let start = (pageNo - 1) * pageLength
let count = pageLength
`SELECT article.id article_id, test.id test_id From article, test WHERE article.id = test.id AND artivle.status In(1) LIMIT ${start}, ${count}`
模糊查询
let sql = `SELECT article.name, test.title FROM article,test WHERE article.id=test.id AND article.name LIKE '%${title}%' AND status IN(1) LIMIT ${start}, ${count}`
函数
count(*) / count(1) 总数
distinct(name) 去重
原文地址:https://www.cnblogs.com/webchenhan/p/10595505.html
时间: 2024-10-12 06:15:17