如何 select 来自 table 的所有数据,其中来自另一个 table 的数据在另一个 table 中具有外键

How to select all the data from a table in which the data from another table is something having foreign key in another table

所以在我的数据库中,我的 table 是这样的:My tables in my database。所以我有一个太多的关系,其中 1 门课程可以有很多模块。所以在我的 java 模块 JTable 中,我只想显示那些 courseName courseStatus 打开的模块数据,并丢弃那些被取消的数据。 所以我尝试了: SELECT * FROM modules WHERE coursesName.courseStatus = 'Open'。但这似乎不起作用,所以我如何使用我在模块 table

中设置的外键 courseName 进行检查

试试这样的东西:

Select * FROM modules m, courses c WHERE c.courseName=m.courseName and c.courseStatus = 'Open'

Select * FROM modules m
join courses c on c.courseName=m.courseName
WHERE c.courseStatus = 'Open'