I was working on this query and just don't know how to use a inner join on 3 different tables where one table is linked with the other 2 tables only.
Individual queries work fine:
SELECT sl_letter_batch,cctvpcn_run_date,cctvpcn_post_date
FROM cctvpcn_batches,statutory_letter
WHERE sl_system_ref = 1095278 and sl_letter_batch = cctvpcn_batch
ORDER BY cctvpcn_run_date
SELECT sl_letter_batch,nto_run_date,nto_post_date
FROM nto_batches,statutory_letter
WHERE sl_system_ref = 1095278 and sl_letter_batch = nto_batch
ORDER BY nto_run_date
Now if I want to inner join the same tables :
SELECT sl_letter_batch,cctvpcn_run_date,cctvpcn_post_date
FROM cctvpcn_batches,statutory_letter
INNER JOIN nto_batches,statutory_letter and sl_letter_batch = nto_batch
and sl_letter_batch = cctvpcn_batch
WHERE sl_system_ref = 1095278
ORDER BY nto_run_date
I know this is a syntax error just trying something different. Because sl_letter_batch has different values in two tables. the result I get is null.
sl_letter_batch cctvpcn_run_date cctvpcn_post_date
21326 2014-10-07 12:45:06.000 2014-10-07 00:00:00.000
21571 2014-11-25 14:13:55.000 2014-11-25 00:00:00.000
sl_letter_batch nto_run_date nto_post_date
21502 2014-11-13 09:06:24.000 2014-11-13 00:00:00.000
21785 2015-01-05 14:30:42.000 2015-01-05 00:00:00.000
IS there anyway to write this query to get both table results with a join.