首页 > 代码库 > MySQL 基础知识 增删改查基本操作

MySQL 基础知识 增删改查基本操作

增删改查=CRUD

增 insert
INSERT car VALUES(‘字符‘,‘name‘,‘brand‘,‘1990-02-02 00:00:00‘) 添加一条

INSERT car (`code`,`name`)VALUES(‘1‘,‘2‘) 单独添加

删除 DELETE 不常用
DELETE FROM car 删除表的所有信息
DELETE FROM car WHERE `Code`=‘字符‘ AND `Name`=‘name‘
DELETE FROM car WHERE `Code`=‘字符‘ OR `Name`=‘name‘

前台的删除 数据库中不删 用isdelect标记


改 UPDATE
UPDATE car SET pic=‘1‘ 所有的pic字段变为1
UPDATE car SET pic=‘1‘ WHERE ??=??

查 SELECT
SELECT * FROM car
SELECT Code,Name FROM car WHERE Code=‘c001‘
SELECT * FROM car WHERE Name LIKE ‘%A6L%‘
SELECT * FROM car ORDER BY Exhaust DESC 从大到下
SELECT * FROM car ORDER BY Exhaust ASC ,Price ASC 从小到大 如果Exhaust相同 Price排列从小到

MySQL 基础知识 增删改查基本操作