In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Single table query operation of the database? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
A single table query refers to a query that performs data in a table, and its execution order is "from- > where- > group by- > having- > distinct- > order by- > limit- > select".
In database operations, a single table query is a query of data in a table, and its syntax is as follows:
Select distinct field 1, field 2... From table name filter condition before where grouping group by grouping field filter condition order by sort field after having grouping number of entries displayed by limit
Syntax is a kind of order, but its execution order is not from the syntax order, but such an order.
From--- > where--- > group by--- > having-- > distinct--- > order by--- > limit--- > select
As for why such an order of execution, I will not say, and I do not have the confidence to say clearly. If the rookie only needs to remember this execution order, if you have to get to the bottom of it, you can go to google.
Before we look at the single table query, let's first create an employee table:
Emp form: employee id id int name emp_name varchar gender sex enum age age int entry date hire_date date job post varchar job description post_comment varchar salary Salary double office office int department code depart_id int
Build a table:
Create table emp (id int not null unique auto_increment,name varchar (20) not null,sex enum ('male','female') not null default' male', age int (3) unsigned not null default 28legendary date date not null,post varchar (50), post_comment varchar (100), salary double (15Ling 2), office int, depart_id int)
Insert data:
Insert into emp (name,sex,age,hire_date,post,salary,office,depart_id) values ('niange','male',23,'20170301','manager',15000,401,1), (' monicx','male',23,'20150302','teacher',16000,401,1), ('wupeiqi','male',25,'20130305','teacher',8300,401,1), (' yuanhao','male',34,'20140701','teacher',3500,401,1), ('anny','female',48,'20150311') 'sale',3000.13,402,2), (' monke','female',38,'20101101','sale',2000.35,402,2), ('sandy','female',18,'20110312','sale',1000.37,402,2), (' chermy','female',18,'20130311','operation',19000,403,3), ('bailes','male',18,'20150411','operation',18000,403,3), (' omg','female',18,'20140512','operation',17000,403,3)
Where conditional filtering
You can use the following in where sentences:
1. Comparison operators: >, =,
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.