天天看點

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

繼續閱讀