Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I'm a freelance consultant, and your site's helped me with many issues. I just wanted you to know that someone does appreciate the intelligent help your site offers."

Geography

Where in the world do Tek-Tips members come from?

Linking 3 tables together by dates and primary key

FB1 (Instructor)
19 Jun 12 9:50
-- HD_OBs (FK_oid is the main link this is the Patientid)
select
oid,
fk_oid,
DIDAT as HDDate,
haloc as location,
access_used

from p_anthropometry
order by didat desc;


-- HD_Prescription (FK_oid is the main link this is the Patientid)
select
oid,
fk_oid,
HWDATE,
HWOACC

from p_hdpresc
order by hwdate desc;

-- Timeline (FK_oid is the main link this is the Patientid)
SELECT oid,
fk_oid,
TXDATE,
TXMOD,
TXREAS,
TXSUPR,
TXSITE

FROM p_timeline
order by txdate desc

I have Three tables with the above fields

HD_Obs will be the main table that will have a between parameter on the date (will be pulling monthly)
I need the other tables to link to the hd_obs table but by date.

i.e yes it must go to the correct Patientid but in HD_obs the date here is the main date per row
DIDAT - FK_oid - haloc -HWDATE - HWOACC TXDATE- TXREAS
02/02/2012 - 12 -- hosp - 30/12/2011 Graft 14/01/2012- Active
01/01/2012 - 12 -- hosp - 12/12/2011 Fistula 01/01/2012 - Active

The dates don’t always correspond with each other, so I need to pull the nearest one below from each table

Your Help is most appreciated, I know it should links on the FK_OID then the date but please how do I write this.
Ralph
barryna (Programmer)
21 Jun 12 1:59
Doing multiple JOINS can be tricky to type outright and get right. I use Microsoft Access, build copies of my tables, and use their query design tool to help build joins more seamlessly. This helps saves time so you can focus on the more important stuff. There are very slight syntax differences between the two, but no an issue if you just want to know what the join code needs to be. Helps me every time.

Creator of www.meltedjoystick.com - Game Reviews, Game Lists, and much more!

FB1 (Instructor)
23 Jun 12 2:06
Due to the nature of the business, Access cannot be loaded onto the pc's
buy thank you any way.

any help in stucturing the query would be most helpful
ralph

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close