MySQL增删查改操作
mysql> insert into mysql_test.cust
-> values(901,'张三','F','北京市','朝阳区');
mysql> select * from mysql_test.cust;
mysql> insert into mysql_test.cust
-> values(902,'王五','F','北京市','朝阳区'),(903,'李四','M','北京市','朝阳区');
mysql> insert into mysql_test.cust
-> values(0,'赵六',default,'北京市',null);
mysql> insert into mysql_test.cust
-> set cust_name='xiaohan',cust_city='北京市',cust_sex=default; //使用insert ... select 语句插入子查询数据
mysql> delete from mysql_test.cust
-> where cust_name='李四';
mysql> update mysql_test.cust
-> set cust_address='武汉市'
-> where cust_name='张三';
mysql> select cust_name,cust_sex,cust_address
-> from mysql_test.cust;
mysql> select * from mysql_test.cust;
mysql> select cust_name,cust_address as dizhi
-> from mysql_test.cust;
mysql> select cust_name,
-> case
-> when cust_sex='M' then '男'
-> else '女'
-> end as 性别
-> from mysql_test.cust;
mysql> select cust_name,cust_sex,cust_id+100
-> from mysql_test.cust;
mysql> select * from tb1 cross join tb2; //交叉连接,又称笛卡尔积 简化:select * from tb1, tb2;
mysql> select * from tb_student inner join tb_score //内连接
-> on tb_student.studentNo=tb_score.studentNo;
mysql> select * from tb_student left outer join tb_score //左外连接 简化:left join 右外连接同理
-> on tb_student.studentNo=tb_score.studentNo;