MySQL基礎 案例講解

2021-10-08 10:32:08 字數 763 閱讀 2680

#案例1:查詢員工的姓名和部門編號和年薪,按年薪降序,姓名公升序。

select last_name,department_id,salary*12*

(1+ifnull

(commission_pct,0)

) from employees order by salary*12*

(1+ifnull

(commission_pct,0)

) desc ,last_name asc;

#案例2選擇工資不在8000到17000的員工姓名和工資,按工資降序

select last_name,salary from employees

where salary<

8000 or salary>

17000 order by salary desc;

select last_name,salary from employees

where salary not between 8000 and 17000 order by salary desc;

#案例3查詢郵箱中包含e的員工,並先按郵箱的位元組數降序,再按部門號公升序

select *

,length

(email) from employees where email like '%e%'

order by length

(email) desc,department_id asc;

Python操作MySQL實戰案例講解

使用python的pymysql庫連線mysql資料庫 匯入pymysql import pymysql 連線mysql資料庫 輸入資料庫的ip位址,使用者名稱,密碼,埠 db pymysql.connect host 127.0.0.1 user root passwd root port 330...

Python基礎練習題案例講解

1 實現1 100的所有的和 方法1 sum 0 for i in range 1,101 sum i print sum 方法2 num1 int input 請輸入起始數字 num2 int input 請輸入末尾數字 sum num1 num2 num2 2 print int sum 2 實...

PHP之mysql位運算案例講解

位運算,賦值狀態時異或對應位數1的整形,判斷狀態則與運算對應位數1的整形。最大用處就是同時判斷32位狀態,節省儲存空間,便於擴充套件,如果你不知道什麼是位運算的話,那麼請你先去看看基礎的c語言教程吧。與運算 a b 或運算 a b 異或運算 a b 或者你也可以將 與運算理解為 法 例如1 2 3 ...