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

  • Home
  • SEARCH
  • 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 522431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T08:21:12+00:00 2026-05-13T08:21:12+00:00

For about a year now, we’ve been allowing our users to login with usernames

  • 0

For about a year now, we’ve been allowing our users to login with usernames and/or email addresses that are not unique (though each user does have a unique id). Although the system handles duplicate usernames/emails elegantly, we’ve decided to finally enforce unique usernames and email addresses. I’ve been tasked with generating a table in MySQL that will show the duplicates and the tables in which a duplicate’s id is being used (i.e. the tables dependent on the duplicate’s user id, using 1 for true and 0 for false). This table will then be used as a reference once duplicate data is marked for deletion. In short, I’m looking to generate a table something like this:

| User_id |
Username |
Email |
Exists_in_Table1 |
Exists_in_Table2 |
Exists_in_Table3 |

———————————————————————————————————–

| 0001…..|
test1………|
email.|
0……………………..|
0……………………..|
1……………………..|

| 0002…..|
test2………|
email.|
0……………………..|
1……………………..|
1……………………..|

| 0003…..|
test3………|
email.|
1……………………..|
1……………………..|
1……………………..|

It doesn’t matter much how this is accomplished. Since my SQL skills are somewhat lacking, I intended to do this programmatically using PHP and a number of simple SQL queries. However, I believe a single SQL query or a series of queries (without the use of PHP) is the cleanest approach. I know how to query for duplicates, but I can’t seem to figure out how to query multiple tables and join them by the user id in an appropriate manner. I appreciate any and all help with this. Thank you.

  • 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-13T08:21:12+00:00Added an answer on May 13, 2026 at 8:21 am
    SELECT u.User_id, u.Username, u.Email,
     IF(t1.User_id IS NULL, 0, 1) AS Exists_in_Table1,
     IF(t2.User_id IS NULL, 0, 1) AS Exists_in_Table2,
     IF(t3.User_id IS NULL, 0, 1) AS Exists_in_Table3
    FROM Users u
    LEFT OUTER JOIN Table1 t1 USING (User_id)
    LEFT OUTER JOIN Table2 t2 USING (User_id)
    LEFT OUTER JOIN Table3 t3 USING (User_id);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a website that i've been working on for about a year now.
I've been programming c++ for about a year now and when i'm looking about
I have been using DotNetOpenAuth v3.5.0.10357 for about a year now and finally decided
I have been writing C++ Console/CMD-line applications for about a year now and would
For about a year now, I've had problems trying to send and receive email
I've been using Zend Studio for Eclipse for about a year, and our SVN
I have been running zope / plone site for about a year now -
I've been working in Eclipse programming for Android for about a year now. I
I've been programming Android in Eclipse for about a year now and I have
I've been using RXTX for about a year now, without too many problems. I

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.