问题描述
我有2张桌子,活动和志愿者
在活动表中包含
Activity_ID(PK)
Activity_Name
Activity_StartDate(数据类型日期)
Activity_EndDate(数据类型日期)
和志愿者表由
组成
V_ID(PK)
V_Name
V_StartWorking(数据类型日期)
我只想知道每个志愿者开始后进行了多少活动工作
我已经尝试过功能CROSS JOIN,但是没有用.因此,您对我有什么建议吗?
非常感谢
I have the 2 tables ,Activity and Volunteer
In Activity Table consist of
Activity_ID (PK)
Activity_Name
Activity_StartDate (DataType Date)
Activity_EndDate (DataType Date)
and Volunteer Table consist of
V_ID(PK)
V_Name
V_StartWorking (DataType Date)
I just want to know how many activity was hold after each volunteer startWorking
I have tried Function CROSS JOIN but it did not work. Thus do you have any suggestions for me?
Thanks so much
推荐答案
Activity_ID (PK)
Activity_Name
Activity_StartDate (DataType Date)
Activity_EndDate (DataType Date)
tblvolunteer
tblvolunteer
V_ID(PK)
V_Name
tblRelate
tblRelate
V_ID(FK)
Activity_ID(FK)
V_StartWorking (DataType Date)
现在,使用inner-join或left-join
now, use inner-join or left-join
select Activity_ID,Activity_Name ,Activity_StartDate , Activity_EndDate,V_ID,V_Name,V_StartWorking
from tblrelate r
left join tblActivity a on a.Activity_ID=r.Activity_ID
left join tblvolunteer v on v.V_ID=r.V_ID
祝您编码愉快!
:)
Happy Coding!
:)
select a.* from activity a,volunteer v where a.Activity_StartDate>=v.V_StartWorking
但这会给您重复的记录.
因此,我建议您在这两个表之间有一个映射列或映射表
But this will give you repeated records.
So i will advise you to have a mapping column or mapping table between these two tables
这篇关于没有主键,有什么方法可以计算差异表中的coluum的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!