Mysql operation command (basic)

Create a database

CREATE DATABASE name;

Show all databases

SHOW DATABASES;

Delete Database

DROP DATABASE name;

Select Database

USE DATABASENAME;

Display tables that exist in the current database

SHOW TABLES;

View table structure

DESCRIBE DATABASENAME;

Delete Data Sheet

DROP TABLE NAME (delete content and definition, free up space)

DELETE TABLE NAME (delete content without deleting the definition, not free up space)

All of the data look-up table

SELECT * FROM DATABASENAME;

Query condition (field number equal to 10)

SELECT * FROM DATABASENAME WHERE number=10;

Many conditions (field number equal to 10, the field is equal to class 2)

SELECT * FROM DATABASENAME WHERE number=10 AND class="2";

Ordering query results (ranked in descending order according to id)

SELECT * FROM DATABASENAME WHERE number=10 ORDER BY id DESC

Note: The default use the ORDER BY sort in ascending, descending you need to use DESC

United-table query

Union query, these table to figure out which field is to be queried intersection, you can query through the intersection of field

select * from Table A, Table B where Table A.XXX = Table B.XXX

 Paging query

select * from table limit m, n (m-th data from the query to n pieces of data)

 

Guess you like

Origin www.cnblogs.com/linxiu-0925/p/11689857.html