Mysql database functions

Source: Internet
Author: User

Mysql database functions

Query statement:
SELECT field name FROM table name.
Sort order by field name to be sorted desc: query in reverse order.
The number of limit queries starting from the specified number: the specified number.
Separate multiple fields with commas.
For example, to query all the data in the table, enter "*" in the field name "*".
If you only want to display the first few characters of a field, you can use the LEFT function.
SELECT field name, LEFT (field name, number of digits), field name FROM table name.
COUNT: function (id) of the total number of records)
AVG: average value function.
MIN: Minimum value function.
MAX: maximum value function.
SUM: The SUM function.
WHERE: limits the returned results.
The LIKE keyword tells MySQL that the specified field matches the given expression, for example, SELECT field name FROM table name WHERE field name LIKE "% word %" AND time> = "2009-01-01" AND time <"2009-02-01 ";
Indicates the record of the word to be searched for in August.
Connect to the database: mysql-h host Delete statement:
Delete from table name WHERE field name LIKE "% words to DELETE %"
Delete from table name <a table is cleared>
Update statement:
UPDATE table name SET content to be updated <date = "2009-01-01"> WHERE field name <ID = "1"> LIKE "% field content %"
CREATE Database TABLE: name of the TABLE to be created in create table.
To view the detailed information of a newly created table: DESCRIBE the name of the newly created table.
Export databases and tables:
Mysqldump-u username-p database name.
Mysqldump-u username-p database name table name.
To export other data in the database, see page 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 and Time type:
Date: date type.
Time: time type.
Datetime: Date and Time type. <Y-m-d H: m: s>
Database numeric type:
TINYINT: 1 byte 255
SMALLINT: 2 bytes 65535
MEDIUMINT: 3 bytes 16777215
INT: 4 bytes 4294967295
BIGINT: 8-byte 18446744073709551615
Session_unregister (name of the variable to be deleted, such as $ _ SESSION ["..."]) can delete a SESSION variable. The unset () function serves the same purpose as this function.
Session_destroy (none) ends the current session. This function has no parameters and returns true.
Session_start (none) initializes a session or continues the current session.
Session_decode (the data to be decoded) decrypts the current session content encrypted with session_encode.
Require (), require_once (), include (), include_once () calls the function of the external file.
Header ("location: address to be transferred") Jump to the connection.
Mysql_fetch_array () retrieves a row from the result set as an associated array, or an array of numbers, or both.
Mysql_fetch_row () retrieves a row from the result set as an enumerated array.
Mysql_fetch_lengths () gets the length of each output in the result set. If the execution fails, false is returned. The first subscript of the returned array is 0.
Mysql_data_seek () can move the internal return pointer. if the pointer is successfully returned, true is returned. If the pointer fails, false is returned.
The field name of the specified field in the result obtained by mysql_field_name.
Mysql_field_table () obtains the name of the data table where the specified field is located.
Mysql_field_len () returns the length of the specified field.
Mysql_num_fields () obtains the number of returned fields.
Mysql_num_rows () obtains the number of returned rows.
Mysql_list_tables () lists the data tables of a specified database.
Mysql_tablename () to get the name of the data table.
Mysql_affected_rows () obtains the number of rows affected by the previous MySQL operation.
Error Code returned by mysql_errno.
Mysql_error () returns an error message.
Mysql_insert_id () obtains the ID generated by the previous INSERT operation.

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.