SQL Getting Started Tutorial

Source: Internet
Author: User

Just we learn in the process of oh, below we will look at the MySQL to Oh, good crap don't say more we take a look at the tutorial.

Query statement:
SELECT field name from table name.
Sort order by the name of the field to sort by desc: query in reverse order.
Limit how many to start from: Find a specified number.
Querying multiple fields at the same time is separated by ",".
If all the data in the query form is filled with "*" in the field name.
You can use the left function if you want to display only the first few characters of a field.
SELECT field name, Left (field name, number of digits), field name from table name.
COUNT: Function with total records (ID)
AVG: the average function.
Min: The minimum value function.
Max: A function of the maximum value.
Sum: the function to sum.
WHERE: The result returned is limited.
The LIKE keyword tells MySQL that the specified field matches the given expression, such as the Select Field name from table name WHERE field name like "%" and time >= "2009-01-01" and Time < "2009-02-01";
said: To find the word February record.
Connection database: Mysql-h host< host >-u user< user name >-p Enter password ******< password >
To delete a statement:
Delete from table name WHERE field name like "% to delete"
DELETE from table name < will empty a table >
UPDATE statement:
Update table name SET What to update <date= "2009-01-01" > WHERE field Name <id= "1" > like "% Field content%"
Create a database table: CREATE table creates a name for the tables.
To view the details of a newly created table: DESCRIBE The name of the table you just created.
exporting databases and tables:
Mysqldump-u user name-p database name.
Mysqldump-u user name-P database name table name.
To export other data in the database, see Book 181.
Insert data:
INSERT into table name (field name, field name ...) VALUES ("corresponding field value", "corresponding field value" ...)
Database String Type:
Char: fixed-length type.
VARCHAR: variable length type, length +1.
Database Date Time Type:
Date: Day type.
Time: Date type.
DateTime: Date-time type. <y-m-d h:m:s>
Database Number Type:
Tinyint:1 byte 255
Smallint:2 byte 65535
Mediumint:3 byte 16777215
Int:4 byte 4294967295
Bigint:8 byte 18446744073709551615
Session_unregister (the variable name to be removed, such as $_session["..."]) can delete a session variable, where the unset () function is equivalent to this function.
Session_destroy (none) ends the current session, this function has no arguments, and the return value is true.
Session_Start (None) Initializes a session or continues the current session.
Session_decode (the data to decode) decrypts a current session content that is encrypted using Session_encode ().
Require (), require_once (), include (), include_once () a function that calls an external file.
Header ("Location: Address to go to") jumps the connection.

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.