MySQL基礎考題(1)

2021-10-06 09:17:38 字數 1925 閱讀 2238

資料庫設計

使用者基本資訊表user_property

使用者好友關係user_friend_relation

愛好字典表hobby_dict

資料庫操作

有如下幾張表

使用者基本資訊表user_property

使用者好友關係表user_friend_relation

愛好字典表hobby_dict

1.查詢小於26歲的使用者資訊,展示使用者的基本資訊(暱稱,郵箱,性別,年齡):

2,頁面需要展示lelei使用者的基本資訊(暱稱,郵箱,性別,愛好),請設計相關sql:

3,頁面需要展示xiaoqoang使用者關於籃球愛好的好友推薦資訊,展示內容包含推薦好友的基本資訊(暱稱,年齡,性別,郵箱,愛好),並按年齡倒序排序

解法1:

select p.nikename,age,***,email,h.hobby_value from user_property p

left join user_friend_relation f on p.usename=f.friend_id

left join hobby_dict h on f.hobby=h.hobby_key where f.usename="xiaoqiang"and h.hobby_value=「籃球」

解法2:

select * from user_property as p

inner join hobby_dict as h

on p.hobbie like concat(』%』,h.hobby_key,』%』) and h.hobby_value=『籃球』

where p.usename

in (select friend_id from user_friend_relation where usename=『xiaoqiang』);

Shell的基礎考題二

1.計算根分割槽的磁碟使用率,百分比精確到2位小數 root server0 df 檔案系統 1k 塊 已用 可用 已用 掛載點 dev vda1 10473900 3124228 7349672 30 devtmpfs 927072 0 927072 0 dev tmpfs 942660 80 9...

Python基礎 面試常考題

python強大的功能 a i for i in range 1000 print a b a i i for i in range len a 輸出1,5,9 b a i 2 i for i in range len a 輸出 1,5,7 print b 金典題目 a 2 j 1 i j for ...

mysql 使用基礎 1

使用命令列連線 mysql mysql uroot p passowrd hlocalhost p port code mysql show databases 顯示資料庫 mysql use test 使用 test 資料庫 mysql show tables 顯示表資訊 mysql descri...