天天看点

MySQL基础

a)插入数据

insert into t_user (id, name,password, age, gender) values (null, "zhangsan", "123456", 21, "男");

insert into t_user values(null, 'lucy', 'lucyx', '111111', 22, '女');

Insert into 表名(字段名称) values(字段值);

b)更新数据

update t_user set user_name = 'xyc' where id = 1;

update t_user set user_name = concat(user_name, '-change') where id =     1;           

Update 表名 set 要更改的字段名=值 where 条件[and/or]

c)删除数据

delete from t_user where id = 3;

Delete from 表名 where 条件[and/or]

d)基本查询语句

select * from t_user;

select * from t_user where id = 1 ;           

Select user_name from t_user; 只查询user_name字段值

Select 字段名 from 表名 where 条件[and/or]; “*”符号代表查询所有 字段

上一篇: MySQL基础3
下一篇: MySQL基础2

继续阅读