数据库和语言关系不大,咱就是复习复习
1.1 增加数据
insert into table_name (column1, column2, column3, ...)
values (value1, value2, value3, ...);
1.2 删除数据
delete from table_name
where some_column = some_value;
1.3 修改数据
update table_name
set some_column = some_value
where some_column = some_value;
1.4 查询数据
select column1, column2, ...
from table_name
where some_column = some_value;
文档:https://www.runoob.com/sql/sql-tutorial.html
mysql也有nodejs的库,可以直接使用
import mysql from 'mysql';
const db = mysql.createConnection({
host: 'localhost',
user: 'your_username',
password: 'your_password',
database: 'your_database_name'
});
可以看看基础使用,但是 medium 上的文章有时候会被墙 https://anujdarji100737.medium.com/building-a-mysql-database-connection-with-node-js-and-express-b6b333f6e713
然后sql
语法看看这个
https://www.runoob.com/sql/sql-tutorial.html