Results 1 to 8 of 8
  1. #1
    bahalzamon is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23

    Self Join 3 Extra Results


    I have a table being pulled from SharePoint into Access. I have the same table brought in 3x naming them Acquisition, Disposition, & Rehab.
    Essentially it houses info for things happening to certain addresses, so for example there is a property that has an Acquisition (bought), then Rehab (work on property) tasks are done, then a Disposition (sell property).

    So I modeled the query off of an old SQL query and its not functioning the same way, i'm sure its just me not understanding the differences of SQL Server vs Access SQL. =P
    Using SQL Server I get one record with all the info i need, but in Access i get 4 records. It looks like its doing some sort of FULL JOIN.


    Code:
    SELECT Disposition.ID, Acquisition.[Content Type], Disposition.[Property Address], Acquisition.[Acquisition Price], Acquisition.[Begin/Contract Date], Acquisition.[End/Close Date], Disposition.[End/Close Date], Disposition.[Sales Price], Disposition.[Appraised Value], Disposition.[Home Buyer/Renter AMI], Disposition.[Annual Household Income], Disposition.[Members in Household], Acquisition.[Begin/Contract Date], Acquisition.[Obligated Amount], Rehab.[Expended Amount], Disposition.[Content Type]FROM ([XXX-Activity] AS Disposition LEFT JOIN [XXX-Activity] AS Acquisition ON Disposition.[Property Address] = Acquisition.[Property Address]) LEFT JOIN [XXX-Activity] AS Rehab ON Disposition.[Property Address] = Rehab.[Property Address]
    WHERE Disposition.[Content Type] Like "*Disposition*";
    If I am missing anything please let me know I will attempt to add and any Suggestions are welcome. =)

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Each dataset has only 1 record for each property?

    I had no problem getting 1 record for each property. Assumes every property has an Acquisition record.

    SELECT ...
    FROM Rehab RIGHT JOIN (Disposition RIGHT JOIN Acquisition
    ON Disposition.[Property Address] = Acquisition.[Property Address])
    ON Rehab.[Property Address] = Acquisition.[Property Address];
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bahalzamon is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23
    There is 1 acquisition and 1 disposition with no rehab. I did find a way around but i am unsure if it would cause any performance issues as the data-set gets larger.
    But I ended up creating 3 queries, one with a filter for dispositions, one for acquisitions, etc... then joined them in the same manner in a fourth query but this time it works using the previously created queries. =/

    I would definitely still love to figure it out though. =P

    Here is all the other info for this query in case it helps point me in the correct direction.
    Results with some info hidden, i accidentally clipped off the id, but they all say 120, same Disposition.ID.
    Click image for larger version. 

Name:	8-28-2020 3-58-12 PM.jpg 
Views:	15 
Size:	37.2 KB 
ID:	42852

    Design Query
    Click image for larger version. 

Name:	8-28-2020 3-59-05 PM.jpg 
Views:	15 
Size:	27.5 KB 
ID:	42853

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    That is exactly what I did. Not sure there would be any other way to accomplish.

    So my question - What exactly is coming from SharePoint when you try to pull in table 3 times with each limited to specific ContentType? Because if the datasets are not truly filtered then the result would be the unexpected output you originally described.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    bahalzamon is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23
    Well how I had it was the table brought in 3x and named the tables Disposition, Acquisition and Rehab.
    I think the issue I was having is that running a query like this within SQL would have returned the 1 record as I was expecting, but Access seems to run a bit different. =P
    So moving forward I will attempt to keep that in mind. =)

    I appreciate the help @June7

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    So apparently your original datasets were not filtered.

    What do you mean by 'within SQL' - Access is using SQL.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    bahalzamon is offline Novice
    Windows 10 Access 2016
    Join Date
    Aug 2015
    Location
    Phoenix, AZ
    Posts
    23
    @June7 you are correct, I should have had the Where clause updated to something like the below. =P
    Code:
    WHERE Disposition.[Content Type] Like "*Disposition*" AND Acquisition.[Content Type] Like "*Acquisition*" AND Rehab.[Content Type] Like "*Rehab*";

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    I don't think the AND operator would have given what you want. I doubt any record could meet that criteria. And if you used OR operator then the dataset would have all 3 record types and you would get the same result as originally when self-joining.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help on left join and limiting results
    By scott0_1 in forum Queries
    Replies: 7
    Last Post: 06-14-2018, 04:29 PM
  2. Replies: 12
    Last Post: 09-10-2015, 05:33 PM
  3. Unexpected results on Inner Join
    By Access_Novice in forum Access
    Replies: 2
    Last Post: 09-05-2014, 12:50 AM
  4. Help with SQL join results
    By ynotaz in forum Programming
    Replies: 6
    Last Post: 08-18-2014, 06:37 PM
  5. Replies: 3
    Last Post: 05-01-2013, 09:52 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums