15-07-16 Database--Delete and change

Source: Internet
Author: User

The string is enclosed in single quotation marks

The comparison in the database is =, not the double equals sign

Logic and

Logical OR OR

Logical non-not

CRUD Operations

I. C:create added, created, adds data to the database.

Insert into table name values (' K009 ', ' Apple ', 3.0, ' gaoqing ', 90, ')--add data to parentheses

Insert into table name (ids,name,price,source,numbers, column name) VALUES (' K010 ', ' Apple ', 3.0, ' gaoqing ', 90, data)

Two. R:retrieve search, query, query data from the database.

A row in a database table is called a record, and a column is called a field.

The query does not modify the actual table data for display purposes only.

Three. U:update modify the data from the database table.

Update table name set column name = ' data ' where row name = ' which line '

Four. D:delete Delete, delete data from the database.

Delete from table name where column name = ' Data '

Transaction: An error has occurred and can be rolled back

Add transaction: Begin Tarn--Add restore point

Rollback: rollback--restore

--Query

1. Query all select * FROM table names

2. Check the specified column select column name 1, column name 2 from table name--Chado column separated by commas

3. Replace column name Select column name ' Replace name ' from table name--replace multiple column names separated by commas

4. Check the specified line select * from table name where column name = ' Data '--* denotes all

5. Check the specified row by condition check select * FROM table name where column name = ' data ' and column name = ' Data '

6. Check the specified row by range select * from table name where column name between 2.0 and 4.0--2.0 to 4.0 data

7. Check the specified line, discrete check select * FROM table name where column name in (90,80,70)--Check the column that appears 90.80.70

8. Go to re-query select DISTINCT column name from table name--Remove duplicate query

9. Fuzzy Query select * FROM table name where column name like '% account '-check end of account

SELECT * FROM table name where column name like ' Account% '-Check with account opening

SELECT * FROM table name where column name like '% account% '-check to include account

SELECT * FROM table name where column name like '% account _ '-check account after only one character

10. Sort By Column name select * FROM table name ORDER BY column ASC-row ascending By column name, if not ASC by default in ascending order

SELECT * FROM table name ORDER BY listing desc-Sort By column name in descending order

SELECT * FROM table name order BY column name 1, column name 2--first column name followed by the last column name row

11. Return Data Select COUNT (*) from table name--Returns how many data are in the table

Average select AVG (column name) from table name--Returns the average of a column

Sum select SUM (column name) from table name--Returns all data for a column and

Max select max (column name) from table name--Returns the maximum value in a column

Min. Select min (column name) from table name--Returns the minimum value in a column

12. Add a new column of SELECT *, (column name *0.8) as ' discounted price ' from table name-add a column that is not in the database, here is the price column after adding 80 percent

13. Group Select column names by column name, COUNT (*) from table name Group BY column name

Filter Select column name after grouping, COUNT (*) from table name Group BY column name having COUNT (*) >1--data that is greater than 1 is returned according to a column group

15-07-16 Database--Delete and change

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.