About MySQL-related view display information:

Source: Internet
Author: User

About MySQL related view display information: Database scope:

First, view all databases: (just look at the number of databases and name)

mysql> show databases;

Second, to view the creation of a database information: (mainly see database options such as Character set)

Here we lock the PHP25 database (use PHP25;)

Mysql> Show CREATE Database

Data table range (use PHP25 in advance; class data table for example):

Third, look at all the data tables in the database: (only the number and name of the data table)

Mysql> Show tables;

Iv. Viewing the creation information for a data table: (Can see field options information, data table options information)

Mysql> Show create table class;

Five: View field information for a data table: (table format displays the field information of the data table for better viewing)

Mysql> DESC class;

Recording Range:

Vi. view all records for all fields in a data table:

mysql> SELECT * from class where 1 ;

VII. View all records for a field in a data table:

For example, all records for the name field of the class table

Mysql> select name from class where 1;

Viii. to view the filtered records for a field in a datasheet:

For example, the name field of the class table filters the records for the sex man

Mysql> select name from class where sex= ' man ';

Ix. to view the filtered records for multiple fields in a data table:

For example, the name field of the class table and the filter for the Sex field record for man

Mysql> Select Name,sex from class where sex= ' man ';

Use five sub-queries to view records:

First, the field records for our table are as follows:

And look at what five sub-queries are.

Five sub-queries are "WHERE clause" "Group BU clause" "HAVING clause" "ORDER BY clause" "Limit clause"

Note that the order cannot be reversed!

Application of the WHERE clause:

X. (where) view the filtered records for a data table:

See all records in the class table id<3

Mysql> SELECT * from class where id<3;

The use of the GROUP BY clause:

Xi. (Gruup by) view a record of a data table by a group:

See the Class table in the Black Team by flag (note that the first record of each group is shown here)

Mysql> SELECT * from class where 1 group by flag;

The use of having clauses:

12. (having) view the filtered records that have been processed by a data table:

View the record of the filtered id=1 after viewing the class table with the black team by flag

Mysql> SELECT * from class where 1 group by flag has id=1;

Application of the ORDER BY clause:

13. (oder by) View the records of a data table in a certain order:

See all records in the class table, view records in descending order of IDs (from big to small)

ASC is ascending (default) desc is descending

Mysql> SELECT * from class where 1 order by id DESC;

Use of the LIMIT clause:

14, (limit) to see the records of a data table, the number of records from the first:

See the class table from the second record (id=2) to see two records (effect is to see ID=2/3 Records)

Note that the first record starts at 0.

Mysql> SELECT * from class where 1 limit 1, 2;

About MySQL-related view display information:

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.