SQL如何在特定日期之前显示数据

SQL如何在特定日期之前显示数据

本文介绍了SQL如何在特定日期之前显示数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个桌子。一个是 worker表,其中显示了工作程序代码,名字和姓氏。
工作日期,其中显示了工作人员代码,工作开始日期,结束日期和工作区域代码。
主管具有工作人员编号,名字,姓氏和工作区号。
工作区具有工作区代码名称和主管。

I have a couple of tables. One is a worker table which displays worker code, firstname and lastname.Job dates which shows worker code, date of job start, end and job area code.Supervisor has worker number, firstname, surname and job area code.Job area has job area code name and supervisor.

我要做的是在日期之前显示工作人员代码2010年10月9日
由于我是新手,因此在建立数据库之前,我会先尝试全部进行书面和理论研究。

What I'm trying to do is display the worker code before date 10/09/10Since I am new to this, I'm trying to do it all written and theory first before making the database.

这样做听起来对吗?我不太确定日期。

Does this sound right? I'm not too sure about the date thing.

select worker
From Job Dates
where job start < '10/09/10'

从理论上讲,这听起来对我来说是正确的,但是否需要告诉查询它是日期戳吗?

In theory this sounds right to me, but does it somehow need to tell the query it is a date stamp?

如果工人在10/09之前开始工作,那么我想查找工人的姓氏和主管的姓氏。 / 10?我猜这将是一个JOIN吗?

I then want to find the surname of workers and the surnames of their supervisor if the workers started the job before the 10/09/10? I'm guessing this will be with a JOIN?

谢谢

推荐答案

您在正确的轨道上。不知道数据库的架构,最终查询将如下所示:

You're on the right track. Not knowing the schema of your database, your ultimate query will look something like this:

select w.surname, s.surname
From worker w INNER JOIN JobDatesTable jdt on w.id = jdt.id
              INNER JOIN SuperVisor s on w.id = s.id
where jdt.jobstart < '20101009'

这篇关于SQL如何在特定日期之前显示数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 13:55