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 7742597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T09:18:56+00:00 2026-06-01T09:18:56+00:00

I have two tables in a SQLite DB, and both have the following fields:

  • 0

I have two tables in a SQLite DB, and both have the following fields:

idnumber, firstname, middlename, lastname, email, login

One table has all of these populated, the other doesn’t have the idnumber, or middle name populated.

I’d LIKE to be able to do something like:

select idnumber, firstname, middlename, lastname, email, login 
from users1,users2 group by login;

But I get an “ambiguous” error. Doing something like:

select idnumber, firstname, middlename, lastname, email, login from users1 
union 
select idnumber, firstname, middlename, lastname, email, login from users2;

LOOKS like it works, but I see duplicates. my understanding is that union shouldn’t allow duplicates, but maybe they’re not real duplicates since the second user table doesn’t have all the fields populated (e.g. “20, bob, alan, smith, bob@bob.com, bob” is not the same as “NULL, bob, NULL, smith, bob@bob.com, bob”).

Any ideas? What am I missing? All I want to do is dedupe based on “login”.

Thanks!

  • 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-06-01T09:18:57+00:00Added an answer on June 1, 2026 at 9:18 am

    As you say union will remove duplicate records (note that union all won’t!). Two records are considered duplicates when all their column values match. In the example you considered in your question it is clear that NULL is not equal to 20 or 'alan' so those records won’t be considered duplicates.

    Edit:

    […] the only way I can think would be creating a new table […]

    That is not necessary. I think you can do the following:

    select login, max(idnumber), max(firstname), max(middlename), max(lastname),
      max(email) from (
        select idnumber, firstname, middlename, lastname, email, login from users1 
        union 
        select idnumber, firstname, middlename, lastname, email, login from users2
    ) final
    group by login
    

    However, if you’re sure that you only have different values on idnumber and middlename you can max only those fields and group by all the rest.

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

Sidebar

Related Questions

I have two sqlite tables, where one table has a foreign key of the
I have two tables, both with start time and end time fields. I need
I have two tables. First one: create table history ( id integer primary key,
Help a sqlite n00b out, please. I have two tables CREATE TABLE students (
I have a SQLITE database with two tables. Table A has an integer timestamp
I have two tables linked by a foreign key. Example: CREATE TABLE one (id
I have two tables, one that contains volunteers, and one that contains venues. Volunteers
I have two SQLite tables, that I would love to join them on a
I have a sqlite query that I'm trying to write. I have two tables:
I have two tables one to store a task and one to evaluate the

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.