46 lines
831 B
SQL
46 lines
831 B
SQL
/* Select all rows from left table which aren't in right table.
|
|
|
|
SELECT l.*
|
|
FROM t_left l
|
|
LEFT JOIN t_right r
|
|
ON r.value = l.value
|
|
WHERE r.value IS NULL
|
|
*/
|
|
|
|
/*
|
|
TODO Add another layer of JOINs to show the value where name='Received' for
|
|
the missing hashes. Maybe we can parse dates from there.
|
|
*/
|
|
SELECT
|
|
h.hash,
|
|
h.name,
|
|
substring(h.value, 0, 40)
|
|
FROM
|
|
header h
|
|
INNER JOIN (
|
|
SELECT
|
|
l.hash
|
|
FROM
|
|
original l
|
|
LEFT JOIN (
|
|
SELECT
|
|
hash
|
|
FROM
|
|
search_header
|
|
WHERE
|
|
name = 'Date'
|
|
) r
|
|
ON
|
|
r.hash = l.hash
|
|
WHERE
|
|
r.hash IS NULL
|
|
) missing
|
|
ON
|
|
missing.hash = h.hash
|
|
WHERE
|
|
-- name IN ('Subject', 'Received', 'Date')
|
|
name IN ('From', 'Subject')
|
|
ORDER BY
|
|
h.value
|
|
;
|