SQL-如何使用日期加入表格以获取所有日期的总体视图
使用定制ERP系统与T&内置。 表1的日期为假期类型,即银行假期,用户预订的假期和用户ID。
表2具有该用户ID的所有时钟 - 因此,时间和日期,时钟,时间和日期,用户ID
可以在一周内显示所有日期,例如通过合并两个表。
例如,表1在星期一有银行假期,用户已经在周二,星期三,星期三,或者根本没有时钟,因为假日桌整个星期都放弃了它们?
Using a bespoke ERP system with T & A built in.
Table 1 has dates with holidays types i.e. bank holidays, user booked holidays - and a user id.
Table 2 has all the clockings for that user id - so, clock in time and date, clock out time and date, user id
Is there a way to show all of the dates in a week, for example by amalgamating the two tables.
E.g. table 1 has a bank holiday on monday, users have clocked tue, wed, thu - or a user hasn't clocked at all because the holiday table has them off all week?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
左JOIN 或右JOIN 将解决问题。
这将加入两个表,包括从“左”表中的空值。右连接对正确的连接也是如此。所有这些都取决于哪个表在外键中引用另一个表。请注意,在此示例中,T1剩下,T2是正确的。
A Left Join or Right Join would do the trick.
This will join the two tables including the null values from the "left" table. Right joins do the same with the right one. All depends on which table references the other in a Foreign Key. Note that in this example T1 is left and T2 is right.