MySql的基本操作

  1. 查询数据: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;

  2.  

    添加数据: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);

  3.  

    修改数据:update tablename set xx=xx,xxx=xx where xxx=xxx and xxx=xxx;

  4.  

    删除数据:delete from tablename where xx=xxx and xxx = xxx or xxx = xxx;

  5.  

    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

posted @ 2017-11-17 22:35  从程序员到外卖小哥  阅读(152)  评论(0编辑  收藏  举报