您的位置:首页 > 编程语言 > PHP开发

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/)

二、语法:

数据类型

描述

应用范围

int,smallint

整型,常用int型,取值最大11位

点击量,编号,真假

char ,varchar

字符串型,char最大取值255字节,varchar更长并伸缩

标题,姓名,关键字

Date,datime

日期型,固定格式:

0000-00-00 00:00:00

float ,double

小数类型,一般设置类型为

(总长度,小数位长度)

价格,科学数值等

Text,longtext

备注型:没有长度限制,但取决于服务器和mysql性能

新闻内容,长内容

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]
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: