zoukankan      html  css  js  c++  java
  • PHP学习之[第08讲]数据库MySQL基础之增删改查

    一、工具:

    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] 

  • 相关阅读:
    操作系统相关知识点
    const define static extern
    Openstack neutron学习
    TensorFlow_Faster_RCNN中demo.py的运行(CPU Only)
    研一前的暑假,深度学习初体验
    List.remove()的使用注意
    iOS开发之多线程(NSThread、NSOperation、GCD)
    PS 滤镜算法原理——碎片效果
    【翻译】ExtJS vs AngularJS
    【翻译】在Ext JS 5应用程序中如何使用路由
  • 原文地址:https://www.cnblogs.com/greywolf/p/4589380.html
Copyright © 2011-2022 走看看