MYSQL学习二

来源:互联网 发布:网络吐槽类节目排行榜 编辑:程序博客网 时间:2024/09/21 06:22

燕十八 公益PHP培训
课堂地址:YY频道88354001
学习社区:
www.zixue.it

增删改查基本操作

5.1 插入数据 insert into 表名(col1,col2,……) values(val1,val2……); -- 插入指定列insert into 表名 values (,,,,); -- 插入所有列insert into 表名 values -- 一次插入多行 (val1,val2……),(val1,val2……),(val1,val2……);

5.3修改数据update tablename set col1=newval1, col2=newval2,......colN=newvalNwhere 条件;

5.4,删除数据 delete from tablenaeme where 条件;

5.5, select 查询 (1) 条件查询 where a. 条件表达式的意义,表达式为真,则该行取出 b. 比较运算符 = ,!=,< > <= >= c. like , not like ('%'匹配任意多个字符,'_'匹配任意单个字符) in , not in , between and d. is null , is not null (2) 分组 group by 一般要配合5个聚合函数使用:max,min,sum,avg,count (3) 筛选 having (4) 排序 order by (5) 限制 limit

6.1, 左连接.. left join .. ontable A left join table B on tableA.col1 = tableB.col2 ; 例句: select 列名 from table A left join table B on tableA.col1 = tableB.col22. 右链接: right join3. 内连接: inner join

7 子查询 where 型子查询:内层sql的返回值在where后作为条件表达式的一部分 例句: select * from tableA where colA = (select colB from tableB where ...); from 型子查询:内层sql查询结果,作为一张表,供外层的sql语句再次查询 例句:select * from (select * from ...) as tableName where ....