I’m trying to match up two bits of data, adding to an existing query.
I’m hoping the query itself explains what i’m trying to do. The line I’m having trouble with is LEFT JOIN practitioners p ON insolvencies.practitioner = practitioners.id,
SELECT DISTINCT i.id AS id,
i.company AS company,
i.insolvencyDate AS insolvency_date,
i.city AS city,
i.createdOn AS createdOn,
1 AS rank_id,
t.entryCopy AS insolvency_type,
i.businessNature AS business_nature,
p.name AS pract_comp_name,
'I' AS i_type
FROM insolvencies i,
LEFT JOIN practitioners p ON insolvencies.practitioner = practitioners.id,
lookupcopy t
WHERE i.checked = 1
AND t.id = i.insolvencyType
AND i.insolvencyDate >= {ts '2010-01-22 00:00:00'}
AND i.insolvencyDate <= {ts '2011-10-20 00:00:00'}
AND (LOWER(p.name) LIKE '%Hodgsons%')
GROUP BY id
I think you are looking for something like this:
The
,between tables is the same asCROSS JOIN.But anyway you should read about
cross join,inner joinandouter joinand use the most appropriate in your case.