Disclaimer: This article is a blogger original article, follow the CC 4.0 by-sa copyright agreement, reproduced, please attach the original source link and this statement.
topic
1. database software installation and configuration
server host installation mariadb server software and remote login database;
installation:
yum install mariadb-server -y
Start the service:
systemctl start mariadb
systemctl enable mariadb
Configure remote login:
mysql_secure_installation # 设置本地密码
systemctl stop firewalld.service # 关火墙
systemctl disable firewalld.service
mysql -uroot -p # 进入数据库
grant all privileges on *.* to root@'172.25.254.68'
identified by 'westos';
# 允许172.25.254.68使用root用户登陆数据库,密码为westos
test:
2. N-th high salary: Get here claim 2 high salary salary
answer:
select Salary from Employee order by Salary asc limit 1,1;
3. Score sorting
Write a SQL query to achieve the score rankings. If the two scores are the same, in accordance id descending
order.
A:
select Id, Score from Score order by Score desc, Id asc;
4. Find duplicate e-mail
answer:
select Email from Email group by Email having count(*)> 1;
5. income employees than managers
answer:
select a.Name from StaffSalare as a,StaffSalare as b
where a.ManageId = b.Id and a.Salary > b.Salary;
6. Never order customers
answer:
select Name as Customers from Customers
where not Customers.Id in
(select Customers from Orders);