我的 sql 个关于从不同表中检索多个值的问题
My sql questions about retrieving multiple values from different tables
MySQL 个表格:
author
(aEmail*
,fName
,lName
,bDate
,city
)
reviewer
(rEmail*
,phoneNumber
,lName
,fName
,city
)
paper
(paperId*
,title
,abstract
,submissionDate
)
author_paper
(authorId*
,paperId*
,isContact
)
paper_review
(paperId*
,reviewerId*
,score
,reviewSubmissionDate
,reviewInvitationDate
)
* = (component of) PRIMARY KEY
我如何在查询中找到发表了 3 篇以上论文且 return 他们的名字并且作者年龄超过特定年龄的作者 (aEmail = authorId)
一个选项使用相关子查询进行过滤:我们可以只计算每个作者在 author_paper
.
中有多少行
select a.*
from author a
where (select count(*) from author_paper ap where ap.authorid = a.id) > 3
我不确定关联条款。也许您想改用作者的电子邮件地址:
where ap.authorid = a.aemail
MySQL 个表格:
author
(aEmail*
,fName
,lName
,bDate
,city
)
reviewer
(rEmail*
,phoneNumber
,lName
,fName
,city
)
paper
(paperId*
,title
,abstract
,submissionDate
)
author_paper
(authorId*
,paperId*
,isContact
)
paper_review
(paperId*
,reviewerId*
,score
,reviewSubmissionDate
,reviewInvitationDate
)
* = (component of) PRIMARY KEY
我如何在查询中找到发表了 3 篇以上论文且 return 他们的名字并且作者年龄超过特定年龄的作者 (aEmail = authorId)
一个选项使用相关子查询进行过滤:我们可以只计算每个作者在 author_paper
.
select a.*
from author a
where (select count(*) from author_paper ap where ap.authorid = a.id) > 3
我不确定关联条款。也许您想改用作者的电子邮件地址:
where ap.authorid = a.aemail