I am working on a parsing program that parses info from two files into a
sqlite3 table.
Lets say the table has the following values:
filename, value2, value3, value4
There are never more than two filename values in the table,
I would like to write a sql query that will join two rows when the following
conditions are true:
- row X:filename != row Y:filename
- row X:value2 == row Y:value2
- row X:value3 == row Y:value3
- row X:value4 == row Y:value4
Ok the actual program I am working on is a little more complicated so maybe this will be a little clearer
file1.txt contents
abcd, 1234, efgh klmn, 5678, opqr stuv, 9abc, wxyz
file2.txt contents
abcd, 1234, efgh klmn, 9ffx, opqr stuv, 9abc, wxyz
Desired Output:
- file1.txt, abcd, 1234, efgh file2.txt, abcd, 1234, efgh
- file1.txt, klmn, 5678, opqr, –, –, –, —
- –,–,–,–, file2.txt klmn, fffx, opqr
- file1.txt, stuv, 9abc, wxyz, file2.txt, stuv, 9abc, wxyz
xbelow is the table nameThere are three parts
min(filename)filters only for unmatched left-file rows.max(filename)filters only for unmatched right-file rows.There is no way to produce your output order exactly (some inherent sort order) unless there exists some line number column, which can be spliced into the query.