SQL getting started
The SQL getting started tutorial is just what we learned in the learning process. Let's take a look at the mysql getting started tutorial below. Let's take a look at the tutorial.
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.