PHP operation MySQL

Source: Internet
Author: User
Tags scalar


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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.