MySql的基本操作
-
查询数据:select * from xxx;
例子:
(1)select id,username,password from t_user;
(2)select id,username,password,gender from t_user where gender = '男';
(3)select id,username,password,gender from t_user where gender is null;
-
添加数据:insert xxx(id, username) values(xx, "xxx");
例子:
insert into t_user(id, username) values(10, "hehehe");
insert into t_user(id, gender, username, age, password) values(15, '男', 'shihu', 18, '123456');
insert into t_user values(16, 'benladeng', '123456', '拉登', 'nan', 18);
-
修改数据:update tablename set xx=xx,xxx=xx where xxx=xxx and xxx=xxx;
-
删除数据:delete from tablename where xx=xxx and xxx = xxx or xxx = xxx;
-
DQL数据查询语言
连接查询
左外连接
select
e.name ename,
e.gender,
d.name dname
from
t_employee e left outer join t_department d
on
e.depart_id = d.id