免責事項:この記事は従って、ブロガーオリジナル記事です。CC BY-SA 4.0再現著作権の契約を、元のソースのリンクと、この文を添付してください。
タイトル
1.データベースソフトウェアのインストールと設定
サーバーホストのインストールmariadbサーバソフトウェアおよびリモートログインデータベースと、
インストール:
yum install mariadb-server -y
サービスを開始します。
systemctl start mariadb
systemctl enable mariadb
リモートログインを設定します。
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
テスト:
2. N番目に高い給料:ここに来る2高給与の給与を主張
回答:
select Salary from Employee order by Salary asc limit 1,1;
3.スコアソート
スコアのランキングを達成するために、SQLクエリを記述します。2つのスコアが従うIDを降順で、同じである場合
順序。
:
select Id, Score from Score order by Score desc, Id asc;
4.重複した電子メールを探します
回答:
select Email from Email group by Email having count(*)> 1;
5.所得の従業員を管理職より
回答:
select a.Name from StaffSalare as a,StaffSalare as b
where a.ManageId = b.Id and a.Salary > b.Salary;
6.顧客を注文することはありません
回答:
select Name as Customers from Customers
where not Customers.Id in
(select Customers from Orders);