Home >Database >Mysql Tutorial >Commonly used basic operation syntax of mysql (4) - simple unconditional query of data and database and table query [command line mode]

Commonly used basic operation syntax of mysql (4) - simple unconditional query of data and database and table query [command line mode]

黄舟
黄舟Original
2017-03-03 14:01:362045browse

1. Mysql simple query: select field 1, field 2... from tablename;


If you write a * in the field, it means querying all The field is equivalent to specifying all field names, so if you want to query the data of all fields, you generally use *.

2. Deduplication query: select distinct field 1, field 2... form tablename;


can be combined with the previous picture To compare the results.

3. Perform the four mathematical operations directly during query, including addition, subtraction, multiplication and division:



##4 , rename the query result fields when querying; select field 1 as name 1, field 2 as name 2... from tablename;



## Use as to rename here. In fact, as can be omitted:



5. Use concat Connect the string to get the query result in a custom format:



6. Suddenly I remembered that there were libraries and tables added before. The deletion operation misses the query operation. Here is the supplement:

Query all databases show databases;

Query all tables under the current database show tables;


The above is the content of mysql common basic operation syntax (4) - simple unconditional query of data and library and table query [command line mode]. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn