PHP学习之[第08讲]数据库MySQL基础之增删改查
2015-06-19 17:53
711 查看
一、工具:
1、phpMyAdmin (http://www.phpmyadmin.net/)
2、Navicat (http://www.navicat.com/)
3、MySQL GUI Tools (http://dev.mysql.com/downloads/gui-tools/)
二、语法:
Insert into 表 (字段1,字段2…)values (值1,值2)
Insert into 表 values (值1,值2)
Insert into 表 set 字段1=值1,字段2=值2,……
Select 字段,字段,…… from 表
Select * 或 函数(字段) from 表
count(*) //统计条数
sum (字段) //求和
avg(字段)//求平均值
max(字段)//求最大值
min (字段)//求最小值
Select 字段,字段,…… from 表 where 条件
字段 【 条件运算符】 值如: = , > , < , <> , and , or
函数:replace()
Select 字段,字段,…… from 表 where 字段 like ‘%值%’
Select 字段,字段,…… from 表 where 字段 not like ‘%值%’
Select 字段,字段,…… from 表 where 字段 in (值,值)
Select 字段,字段,…… from 表 where 字段 not in (值,值)
Select 字段,字段,…… from 表 group by 字段
Select 字段,字段,…… from 表 order by 字段 [asc / desc ]
Select 字段,字段,…… from 表 limit 起始位 ,条数
Select * from user where age<30 group by job order by id desc limit 10
Update 表 set 字段=值 , 字段=值 [where] [group] [order] [limit]
delete from 表 [where] [group] [order] [limit]
1、phpMyAdmin (http://www.phpmyadmin.net/)
2、Navicat (http://www.navicat.com/)
3、MySQL GUI Tools (http://dev.mysql.com/downloads/gui-tools/)
二、语法:
数据类型 | 描述 | 应用范围 |
int,smallint | 整型,常用int型,取值最大11位 | 点击量,编号,真假 |
char ,varchar | 字符串型,char最大取值255字节,varchar更长并伸缩 | 标题,姓名,关键字 |
Date,datime | 日期型,固定格式: 0000-00-00 00:00:00 | |
float ,double | 小数类型,一般设置类型为 (总长度,小数位长度) | 价格,科学数值等 |
Text,longtext | 备注型:没有长度限制,但取决于服务器和mysql性能 | 新闻内容,长内容 |
Insert into 表 values (值1,值2)
Insert into 表 set 字段1=值1,字段2=值2,……
Select 字段,字段,…… from 表
Select * 或 函数(字段) from 表
count(*) //统计条数
sum (字段) //求和
avg(字段)//求平均值
max(字段)//求最大值
min (字段)//求最小值
Select 字段,字段,…… from 表 where 条件
字段 【 条件运算符】 值如: = , > , < , <> , and , or
函数:replace()
Select 字段,字段,…… from 表 where 字段 like ‘%值%’
Select 字段,字段,…… from 表 where 字段 not like ‘%值%’
Select 字段,字段,…… from 表 where 字段 in (值,值)
Select 字段,字段,…… from 表 where 字段 not in (值,值)
Select 字段,字段,…… from 表 group by 字段
Select 字段,字段,…… from 表 order by 字段 [asc / desc ]
Select 字段,字段,…… from 表 limit 起始位 ,条数
Select * from user where age<30 group by job order by id desc limit 10
Update 表 set 字段=值 , 字段=值 [where] [group] [order] [limit]
delete from 表 [where] [group] [order] [limit]
相关文章推荐
- php 控制台打印
- php中explode与split的区别介绍
- PHP将Excel另存为Word
- php魔术方法的使用(总结)
- 3. Laravel5学习笔记:laravel队列使用教程
- 简单灵活的 PHP页面跳转函数
- 分享一个自己写的基于TP的关系模型
- php简单统计字符串单词数量的方法
- PHP对文件夹递归执行chmod命令的方法
- php强制用户转向www域名的方法
- php自动更新版权信息显示的方法
- php衣食父母之3-php利用HHVM实现高性能
- Yii2 学习日志------view form标签
- PHP实现同服务器多个二级域名共享 SESSION
- PHP CI框架学习笔记-分页实现程序
- php中Snoopy类用法实例
- PHP正则把"2010-12-20"替换成"12/20/2010"
- lftp命令使用
- php计算整个目录大小的方法
- php简单计算页面加载时间的方法