簡體   English   中英

從他們屬於MySQL的所有組中選擇用戶

[英]Select user from all groups they belong in MySQL

我將從他們所屬的組中選擇所有用戶。

數據庫是這個。

Classroom Table // This is the GROUP .. or Classroom Group
>classroom_id (pk)
>classroom_name
>classroom_description
>instructor_id


CLassroom Members Table
>classroom_id (fk)
>account_id (fk)

User Table
>account_id (pk)
>account_name

..i已經測試過一些..但是您能不能給我一些建議或sql邏輯

Select * from User as u

Join Classroom Members as cm 
on u.account_id=cm.account_id 

join Classroom as c 
on cm.classroom_id=c.classroom_id

order by c.classroom_id desc
select a.account_name,c.classroom_name,c.classroom_description
from  CLassroom_Members_Table b
join User_Table a
on b.account_id=a.account_id 
join Classroom_Table c
on b.classroom_id= c.classroom_id 
Where instructor_id=1

這給出了教室中所有學生的總詳細信息,其中教師_id = 1

這對您有幫助嗎?

謝謝。

如果有幫助,請標記為答案或對此進行投票

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM