Combining tables in one sql instead of 2 in query (1 Viewer)

jaryszek

Registered User.
Local time
Today, 14:53
Joined
Aug 25, 2016
Messages
756
Hi,

i am trying to do in one query left join like here:



as you can see it will work. Problem is that i have to match not only CustomerTopologyID but also ServerID with ServerIDFK in tblCustomerTopologyServers table.

But when i am doing:

i am getting error.

Please help,
Jacek
 

Attachments

  • Screenshot_32.png
    Screenshot_32.png
    62.8 KB · Views: 122
  • Screenshot_33.png
    Screenshot_33.png
    83.8 KB · Views: 96

MajP

You've got your good things, and you've got mine.
Local time
Today, 17:53
Joined
May 21, 2018
Messages
8,463
I think instead of a join you can do the last one as a where

where qry...Done.serverID = tbl...ServerIDFK
 

CJ_London

Super Moderator
Staff member
Local time
Today, 21:53
Joined
Feb 19, 2013
Messages
16,553
To add to MajPs suggestion, to maintain the left join the criteria needs to be

where qry...Done.serverID = tbl...ServerIDFK OR tbl...ServerIDFK is null

Another way is to combine the two smaller tables -

SELECT *
FROM tbl1 LEFT JOIN (SELECT * FROM tbl2 LEFT JOIN tbl3 ON .....) C ON .....
 

Users who are viewing this thread

Top Bottom