Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4086076
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:40:28+00:00 2026-05-20T18:40:28+00:00

I am working on a parsing program that parses info from two files into

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:40:29+00:00Added an answer on May 20, 2026 at 6:40 pm

    x below is the table name

    select a.*, b.*
    from x as a
    inner join x as b
      on a.filename<b.filename
        and a.value2 = b.value2
            and a.value3 = b.value3
            and a.value4 = b.value4
    union all
    select a.*, b.*
    from x as a
    left join x as b
      on a.filename!=b.filename
            and a.value2 = b.value2
            and a.value3 = b.value3
            and a.value4 = b.value4
    where b.filename is null
      and a.filename = (select min(filename) from x)
    union all
    select b.*, a.*
    from x as a
    left join x as b
      on a.filename!=b.filename
            and a.value2 = b.value2
            and a.value3 = b.value3
            and a.value4 = b.value4
    where b.filename is null
      and a.filename = (select max(filename) from x)
    

    There are three parts

    1. Where all values match between the two files. The lesser file name is listed on the left side
    2. Where the values cannot be matched to the right side. min(filename) filters only for unmatched left-file rows.
    3. Where the values cannot be matched to the left side. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My program has been working perfectly so far, but it turns out that I've
I've written a working program in Python that basically parses a batch of binary
I'm working on an existing data parsing program that overlays a struct onto a
I've created a program that has two projects: a windows UI and an engine.
I been working on parsing out bookmarks from an export file generated by google
I'm looking for good/working/simple to use PHP code for parsing raw email into parts.
I'm working on an iPad app that downloads a CSV file from the web
The program I'm working on reads ResX files and it fails to read this
I'm working on a project that has a proprietary file format. The project has
I did a program that reads rss news feeds. Its not working for some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.