SQL Query to get results that match between three tables, or a single result for no match -


Is there a way where the clause is to check that there are zero matches between the tables for the first table, And displays a line or results?

I am trying to get results which looks like this:

 + ---------- + --- ----- - + ----------- + ---------- + ------------- + | Results | + ---------- + ---------- + ----------- + ---------- + ---- --------- + | Date | Qatar ID | By date To date | Campaign ID. | 3/1/2014 | 1 | 2/24/2014 | 3/2/2014 | 1 | | 3/1/2014 | 2 | (NULL) | (NULL) | (NULL) | + ---------- + ---------- + ----------- + ---------- + ---- --------- + 

Combining tables that look like this:

 + ---------- + ---- --- + ------- + ---- + ---- + ----------- + ----------- + - - ------- + | Table 1 | | Table 2. | Table 3. + ---------- + ------- + + ------- + ---- + + ---- + ---------- - + ----------- + ---------- + | Date | Qatar | | Qatar | SP | SP By date To date | Campaign | | | ID | | ID | ID | | ID | | | ID | + ---------- + ------- + + ------- + ---- + + ---- + ---------- - + ----------- + ---------- + | 3/1/2014 | 1 | | 1 | 1 | | 1 | 2/24/2014 | 3/2/2014 | 1 | | 3/1/2014 | 2 | | 1 | 2 | | 2 | 3/3/2014 | 3/9/2014 | 5 | | | | | 1 | 3 | | 3 | 3/10/2014 | 3/16/2014 | 1 | | | | | 1 | 4 | | 4 | 3/17/2014 | 3/23/2014 | 1 | | | | | 1 | 5 | | 5 | 3/24/2014 | 3/30/2014 | 4 | | | | | 2 | 6 | | 6 | 3/3/2014 | 3/9/2014 | 5 | | | | | 2 | 7 | | 7 | 3/10/2014 | 3/16/2014 | 5 | | | | | 2 | 8 | | 8 | 3/17/2014 | 3/23/2014 | 5 | | | | | 2 | 9 | | 9 | 3/24/2014 | 3/30/2014 | 5 | + ---------- + ------- + + ------- + ---- + + ---- + ---------- - + ----------- + ---------- + 


I am joining Table 1 from Table 1 on Qi ID,
and Table 2 to Table 3 should come between the date id and page between Table 3 and Table 1 between Table 1 and Table 1.

I want to return a single record for each queue, in which there were no date matches, unfortunately, any combination of joining it or as far as I have tried, only resulted in There is a record for Qi ID 1 or many records for each Qi ID.

I can suggest:

  SELECT t1.Date , T1.QueueID, s.FromDate, s.ToDate, s.CampaignID to Table 1 T1 left (SELECT T2.QueueID, T3.FromDate, T3.ToDate, T3.CampaignID to Table 2 T2 INNER T2.SPID = t3 Include on SPID) Enter on T1. Between QueueID = s.QueueID and T1.Date, S date and S. ToDate  


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -