SQL How to display data before a certain date

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.

What I'm trying to do is display the worker code before date 10/09/10 Since 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?

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?

Thanks

3

1 Answer

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' 
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like