Combining tables in one sql instead of 2 in query

jaryszek

Registered User.
Local time
Today, 12:10
Joined
Aug 25, 2016
Messages
756
Hi,

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

attachment.php


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:
attachment.php

i am getting error.

Please help,
Jacek
 

Attachments

  • Screenshot_32.png
    Screenshot_32.png
    62.8 KB · Views: 166
  • Screenshot_33.png
    Screenshot_33.png
    83.8 KB · Views: 137
I think instead of a join you can do the last one as a where

where qry...Done.serverID = tbl...ServerIDFK
 
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

Back
Top Bottom