PHP學習之[第08講]資料庫MySQL基礎之增刪改查

來源:互聯網
上載者:User

標籤:

一、工具:

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] 

PHP學習之[第08講]資料庫MySQL基礎之增刪改查

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.