MySQL(3)表操作
-
新增数据
insert into 表名 (列名,列名,列名) values(对应列的值,对应列的值,对应列的值);insert into tb1(name,password) values('aaaa','123123'); insert into tb1(name,password) values('aaaa','123123'),('alex','123'); insert into tb1 values('aaaa','123123'),('aaaa','123'); -- 如果表中只有2列 # 只有name,password两行 -
删除数据
delete from 表名; delete from 表名 where 条件;delete from tb1; delete from tb1 where name="aaaa"; delete from tb1 where name="aaaa" and password="123"; delete from tb1 where id>9; -
修改数据
update 表名 set 列名=值; update 表名 set 列名=值 where 条件;update tb1 set name="aaaa"; update tb1 set name="aaaa" where id=1; update tb1 set age=age+1; -- 整型 update tb1 set age=age+1 where id=2; update L3 set name=concat(name,"db"); update L3 set name=concat(name,"123") where id=2; -- concat一个函数,可以拼接字符串 -
查询数据
select * from 表名; select 列名,列名,列名 from 表名; select 列名,列名 as 别名,列名 from 表名; select * from 表名 where 条件;select * from tb1; select id,name,age from tb1; select id,name as N,age, from tb1; select id,name as N,age, 111 from tb1; select * from tb1 where id = 1; select * from tb1 where id > 1; select * from tb1 where id != 1; select * from tb1 where name="aaaa" and password="123";
浙公网安备 33010602011771号