ref:https://www.cnblogs.com/bluealine/p/7832219.htmlphp
1)查看錶結構:desc table_name;html
2)查看建立表的sql語句:show create table mytable;mysql
3)select count(username) from user;//count(username)能夠換成count(*),count(0)web
4)union和union all的區別是,union會自動壓縮多個結果集合中的重複結果,而union all則將全部的結果所有顯示出來,不論是不是重複。sql
字段名 | 數字類型 | 數據寬度 | 是否爲空 | 是否主鍵 | 自動增長 | 默認值 |
id | int | 4 | 否 | primary key | auto_increment | |
name | char | 20 | 否 | |||
sex | int | 4 | 否 | 0 | ||
degree | double | 16 | 是 |
FirstName | LastName | Age |
---|---|---|
Peter | Griffin | 35 |
Glenn | Quagmire | 33 |
<?php $con = mysql_connect("localhost","peter","abc123"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("my_db", $con); mysql_query("DELETE FROM Persons WHERE LastName='Griffin'"); mysql_close($con); ?>在此次刪除以後,表是這樣的:
FirstName | LastName | Age |
---|---|---|
Glenn | Quagmire | 33 |