C/s:client Server
B/s:brower Server
PHP Main implementation b/s
Lamp:linux system a Apache server MySQL database php language
MySQL Common code
Create a table
1 Create TableCeShi12 (3Uidvarchar( -)Primary Key,4Pwdvarchar( -),5Namevarchar( -),6Nationvarchar( -),7 Foreign Key(Nation)ReferencesNation (Code)8)
Relational database: There is a relationship between tables and tables
Create several keywords for the table:
1. Primary key: Primary key
2, non-null: NOT NULL
3. Self-growth column: auto_increment
4. Foreign key Relationship: FOREIGN key (column name) references table name (column name)
CRUD Operations:
1. Add Data:
INSERT into Info values (' ', ' ', ' ', ', ')//require the values in the parentheses to be the same as the number of columns in the table
Insert into Info (code,name) VALUES (",") adds the value of the specified column
2. Modify the data
Update Info set name= ' Zhang San ' where Code = ' p001 '
3. Delete data
Delete from Info where code= ' p001 '
Writing query statements requires attention:
1. When creating a table, do not write a comma after the last column.
2. If more than one statement is executed together, note the semicolon-delimited before the statement
3, write code all the symbols are half-width (in English state)
1, ordinary query, poor all
SELECT * FROM Info #差所有数据
Select Code,name from Info #查指定列
2. Condition Inquiry:
SELECT * from Info where code= ' P001 ' #一个条件
SELECT * from Info where Name= ' Zhang San ' and Nation = ' p001 ' #两个条件并列的关系
SELECT * from Info where Name= ' Zhang San ' or Nation = ' p001 ' #两个条件或的关系
3. Sort Query
SELECT * from Info order bu Birthday # default ascending ASC If DESC is sorted in descending order
SELECT * from Car ORDER BY brand,oil DESC # Multi-column sort
4. Aggregation function
Select COUNT (*) from Info #取个数
Select SUM (Price) from Car #查询Price列的和
Select AVG (price) from Car #查询price列的平均值
Select Max from Car #查询price列的最大值
Select min (Price) from Car #查询price列的最小值
5, paging query
SELECT * from Car limit 0,5 #跳过n条数据取m条数据
6. Group Query
Select brand from GROUP BY Brand #简单分组查询
Select brand from GROUP BY Brand has count (*) >2 #查询系列里面车的数量大于2的系列
7, go to re-query
Select distinct brand from car
8. Modify column names
Select Brand as ' series ' from car
9. Fuzzy Query
SELECT * from car where Name like ' _ Dee% '% stands for any number of characters _ represents one character
10. Discrete query
SELECT * from car where code in (' c001 ', ' c002 ', ' c003 ', ' c004 ')
SELECT * from car where code not in (' c001 ', ' c002 ', ' c003 ', ' c004 ')
PHP MySQL Common code, curd operation and simple query