我與表的數據庫:這是連接表來獲取數據的正確方法嗎?
Student(SID,Name,Surname,Age)
Registration(StudentID,CourseID)
Course(CID,Name,Cost)
我想提取與學生的課程超過20個年輕下面的查詢做到這一點只有名字?
SELECT C.NAME
FROM Course C
INNER JOIN Registration
INNER JOIN Student S
WHERE CID = CourseID
AND SID = StudentID
AND Age < 20
GROUP BY C.NAME
我也想提取學生每門課程讓學生比20年輕的數量是否正確,如下辦呢?
SELECT count(S.NAME)
,C.NAME
FROM Student S
INNER JOIN Course C
INNER JOIN Registration
WHERE Age < 20
AND CID = CourseID
AND SID = StudentID
GROUP BY C.NAME
你用什麼db? Mysql還是SQL?有兩個sintax之間的區別 –
@LelioFaieta你可以給我一個鏈接到'SQL'數據庫嗎?我很好奇它與MySQL的區別。 –
@ Lelio - post被標記爲MySQL .... – MuppetGrinder