Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:17:52+00:00 2026-06-02T20:17:52+00:00

This is the table structure (the relevant bits): I’m trying to find the contactLog

  • 0

This is the table structure (the relevant bits):

Basic table structure

I’m trying to find the contactLog entries that match the declarations on clientID and the date of the declaration (within 8 hours actually). Here’s what I came up with:

SELECT
D.ClientID
D.DeclarationID   
CL.ContactDescription,
CL.ContactDate,

FROM Declarations D

INNER JOIN  (Contacts C
         INNER JOIN (PartialContacts PC
             INNER JOIN ContactLogs CL
                ON PC.ContactPartID = CL.ContactPartID )
            on PC.ContactID = C.ContactID
     )  
    ON C.ClientID = D.ClientID AND DATEDIFF(hour, D.DeclarationDate, CL.ContactDate) < 8

However, the join is not functioning properly, because I get non matching dates back for the CL.ContactDate and it’s clear that it’s just return every row in CL for that patient ID. I think… I’m not really sure what is going wrong.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:17:54+00:00Added an answer on June 2, 2026 at 8:17 pm

    Thanks to Damien:

    I did not specify a lower limit for datediff, so the matching did not work properly. Apperently, the joins are just fine:

    SELECT
    D.ClientID
    D.DeclarationID   
    CL.ContactDescription,
    CL.ContactDate,
    
    FROM Declarations D
    
    INNER JOIN  (Contacts C
             INNER JOIN (PartialContacts PC
                 INNER JOIN ContactLogs CL
                    ON PC.ContactPartID = CL.ContactPartID )
                on PC.ContactID = C.ContactID
         )  
        ON C.ClientID = D.ClientID AND DATEDIFF(hour, D.DeclarationDate, CL.ContactDate) < 8 DATEDIFF(hour, D.DeclarationDate, CL.ContactDate) > 0.1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a table structure that looks something like this(some details omitted): ColumnName
First, the relevant bits of the table structure: contact -contactID -email data -value -contactID
Table structure goes something like this: Table: Purchasers Columns: id | organization | city
I have this table structure and would like to map it using Fluent Hibernate
I have my Table structure like this :: ATT_Table : Fields - Act_ID, Assigned_To_ID,
I'm using Hibernate 3.3.1 and am following along in modelling this sample table structure
This is my table structure groupings id groupName 1 group1 2 group2 3 group3
I've got this really basic table structure: Posts PostXTags PostTags There is a 1-n
If I have a table structure like this: Transaction [TransID, ...] Document [DocID, TransID,
I have a table structure like this: <table> <tr> <td> <ul> <li class=check></li> </ul>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.