6.3 Database Deletion and modification

Source: Internet
Author: User

Add Table Data

1 INSERT into car values (', ', ', ', ', ');

2 INSERT into car (field 1, Field 2, ...) VALUES (value 1, value 2, ...);

3 INSERT INTO car set field 1= value One, field 2= value 2, ... ;

modifying table Data

Update car SET field 1= value where field 2= value

Delete table Data

Delete from table name where field 1 = value

================ Simple Query ===============

1 Most simple queries

SELECT * from Car;

2 Querying the specified column

Select Name,oil,powers from Car;

3 Change the name of the identified column names

Select name as ' car name ', oil as ' fuel consumption ', powers as ' power ' from car;

4 Query by condition

Select name, oil,powers from car where oil = 8.7;

More than 5 pieces of query

Select name, oil, powers from car where oil=8.7 or powers = 160;

Select Name,oil, powers from car where oil = 8.7 and powers = 160;

6 Range queries

SELECT * from car where Price>=40and price<=60;

SELECT * from car where price between and 60;

7 Discrete queries

SELECT * from car where powers = powers=150 or powers=170;

Select *from Car where powers in (130,150,170);

SELECT * from car where powers not in (130,150,170);

8 Fuzzy Query

Select *from car where name like '% BMW% ';

SELECT * from car where name like "_ BMW%"; _ Represents a character

9 Sort query ASC Ascending desc Descending order Queueing

SELECT * FROM car order by oil ASC;

SELECT * FROM Car ORDER by brand Asc,price desc;

10 go to duplicate query distinct

Select distinct brand from car;

11 Paged Query

select* from car limit 10, 5;

N:m=5

Limit (n-1) *m,m;

12 Aggregate function queries

Count (column name) sum (column name) AVG (column name) max (column name) min (column name)

Select COUNT (*) from car;

Select SUM (price) from car;

Select AVG (price) from car;

Select Max (price) from car;

Select min (price) from car;

6.3 Database Deletion and modification

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.