SQL statement 2

Source: Internet
Author: User

SQL statement 2
Menu column data
Select name from totoro;
Select two columns of data
Select id, name from totoro;
Non-repeated data in the menu Column
Select distinct name from totoro;
Select the data whose name is pangpang3 in the name column.
Select * from totoro where name = 'pangpang3 ';
Select data age> 3
Select * from totoro where age> 3;
And
Select * from totoro where id = 1 and age = 1;
Or
Select * from totoro where id = 1 or age = 3;
Order by sorting
Select age from totoro order by age;
Select two columns and sort by age
Select id, age from totoro order by age;
DESC, descending order
Select age, name from totoro order by name DESC;
ASC, ascending
Select name, id from totoro order by name ASC;
Partially inserted
Insert into totoro (id, name) values (10, 'feifei ');
Partial update
Update totoro set id = 13, name = 'mark' where age = 9;
Delete
Delete from totoro where id = 1;
Select the first 3 lines of limit
Select * from totoro limit 3;
Name ending with I
Select * from totoro where name like '% I ';
Name with om
Select * from totoro where name like '% om % ';
The first character after name is hu's
Select * from totoro where name like '_ hu ';
Name 2nd is a, 4th is k
Select * from totoro where name like '_ a_k ';
The name is tom, ii
Select * from totoro where name in ('Tom ', 'II ');
Name between anan and mary
Select * from totoro where name between 'ananc' and 'Mary ';
As specified alias
Select name as n from totoro;
Table Name totoro as t
Select t. id from totoro as t;
Names with the same IDs in the two tables
Select totoro. id, totoro. name, user. name from totoro, user where totoro. id = user. id;
Join on
Select totoro. id, totoro. name, user. name from totoro join user on totoro. id = user. id order by totoro. id;
Take the data with the same id as the two tables.
Select totoro. id, totoro. name, user. name from totoro, user where totoro. id = user. id;
Inner join
Select totoro. id, totoro. name, user. id from totoro inner join user on totoro. id = user. id order by totoro. id;

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.