Data processing in SQL:

Source: Internet
Author: User

Tag:des   ar   sp    Data    on   bs    ef   as   sql   

One. Add New data!
Insert single-line record
1.create table box (
name varchar () NOT NULL,
ID int. NOT NULL PRIMARY key,
student varchar, gender char (2) default 0 comment ' 0 male: 1 female '
);
INSERT into box (name, ID, Student) VALUES (' Xiaohong ', 123, ' 123 '), (' Bingxin ', 565, ' 334 ');
Select*from Box;
Insert new data: INSERT into table name (column name) values (list parameters) can also be added, (list parameters);
Insert multiple rows of data: INSERT into < table name > select <select statement;
Insert into games select year+12,city from games;
Insert Inti Students (Studenyname,studenyid) Select Studenyname+2,studenyid from Students.
Two. Update the new data.
1.update Table Name set the value to be changed where < filter conditions;
CREATE table Box3 (
name varchar () NOT NULL,
ID int. NOT NULL Primar Y key,
student varchar,
Gender char (2) default 0 comment ' 0 male: 1 female '
);
Insert into BOX3 (name, ID, Student) VALUES (' minxing ', 365, ' 668 '), (' Lunxun ', 778, ' 388 ');

Update set Box3 name= ' Xiaotao ', id= ' 596 ' where student= ' 668 ';
Delete from Box3 where id= ' 365 ' and student= ' 388 ';
Select*from Box3;
2. Delete data
Delete from table name where < filter conditions >
Delete from Box3 where id= ' 596 ';
Delete from Box3 where id= ' 335 ' and/or name= ' Xiaotao ';

One. Basic structure of the query:
Select column
From table name
where (filtered)
Group by ..... To group
Having a verdict ... Conditions
Order BY (sort) ASC Ascending, desc descending
Two:
Lookup: Select column name from table name
Select Name,student,subject from box;
Alias: Select name ' name ', subject ' award ' from box;
To return a qualified number of rows query:
Select Top 5 student from box (query first to fifth)
Three fuzzy query:
Select *from box where limit 0,4 (O is from 0 lines, 4 refers to length)
Select*from box where like '%liu% ';
Select age from Student order by age DESC limit 0, 8;

Data processing in SQL:

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.