Internal connection
Syntax rules: Select *| Field List from the left table inner join right table on the left table. field = Right table. field;
External connection
1. Left Outer connection:
Syntax rules: The Select *| field list from the left table and the right table on the left outer join. field = Right table. field;
2. Right outer connection:
Syntax rules: The Select *| field list from the left table right outer join to the left table. field = Right table. field;
Natural connection
1. Natural Inner Connection
Syntax: Left table natural INNER join right table
2. Natural outer Connection
Syntax: Left table natural left|right join right Table
Sub-query (scalar quantum query)
Scalar Quantum query: Select field List (function) from data table;
Column query: That is, to return a single row of subqueries
Syntax: Select field from data table;
Row subquery: Returns a row of subqueries.
Grammatical form:
Select *| field list from table name where (field 1, Field 2 ...). ) = (Row subquery result)
Table subquery: Select *| Field List from sub-query result as alias WHERE clause ...
Exists sub-query
Exists is primarily used to make judgments, and the return result is a Boolean value!
Application Scenarios:
Registered users, you must ensure that the user name is not registered, at this time you can first query the user's user name exists!
Syntax form: SELECT EXISTS (SELECT * from table name where ...)
PHP operation MySQL
First step: Establish connection authentication
$link = mysql_connect ("localhost:3306", "root", "password");
Step Two: send operation instructions
$sql = "Set names UTF8";
$result = mysql_query ($sql);
Step three: Return processing results
Var_dump ($result);
Fourth step: Disconnecting
Mysql_close ($link);
PHP Extract Resource result set
PHP Extract Resource result sets are basically implemented using the Mysql_fetch series functions!
The syntax form is: mysql_fetch_array (resource result set)
Error debugging function
Mysql_errno (): Get the wrong number!
Mysql_error (): Get the wrong information!
Encapsulating database Connection files
PHP implementation and additions to the search
Insert Data function: mysql_insert_id ()
Delete and update data
Use function: Mysql_affected_rows ()
PHP operation MySQL