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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:42:05+00:00 2026-05-13T09:42:05+00:00

I have two tables table1 = records, table2 = duplicates. Both tables contain a

  • 0

I have two tables table1 = records, table2 = duplicates. Both tables contain a variable number of columns at any given time and they both contain the exact same columns with the exception of table2 having an additional ID column… Both tables contain a column, user_id. The data comes from a CSV import. If the user_id already exists in table1 it is inserted into table2.

With table2 I need to be able to grab all the rows and print them out in a table, no problem. The part I’m having a hard time figuring out… For each column in table2 that gets printed I need to check if the data matches(based on the user_id) the data in table1 and somehow flag it… (maybe a different color background on the table cell)

Example:

table1 contains the row:

user_id | user_name
-------------------
2342342 | some name

and table2:

user_id | user_name
-------------------
2342342 | different name

then the output would be:

-----------------------------------------
|2342342 | *flag* different name *flag* |
-----------------------------------------

Any idea as to how I could make this work? If it helps any, I’m building this app with Codeigniter.

  • 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-13T09:42:06+00:00Added an answer on May 13, 2026 at 9:42 am

    This query will select all the entries from table2, and if the name is different than the name in table1, is_different will be 1, otherwise it’s 0:

    SELECT
        table2.user_name,
        IF(table2.user_name != table1.user_name, 1, 0) AS is_different
    FROM
        table2
    LEFT JOIN
        table1
    ON
        table1.user_id = table2.user_id
    

    EDIT

    You can do several of those tests in one query, if you need to compare more than one column:

    SELECT
        table2.user_name,
        table2.user_email,
        IF(table2.user_name != table1.user_name, 1, 0) AS is_name_different,
        IF(table2.user_email != table1.user_email, 1, 0) AS is_email_different
    FROM
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 291k
  • Answers 292k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer you could generate js on-the-fly my.js.php: <?php echo "//Yes." ?>… May 13, 2026 at 6:07 pm
  • Editorial Team
    Editorial Team added an answer If you wish to read digits, you need to do… May 13, 2026 at 6:07 pm
  • Editorial Team
    Editorial Team added an answer sizeof(struct sockaddr_un) is fine. Take a look at the manpage… May 13, 2026 at 6:07 pm

Related Questions

I have two tables, A and B and a simple table, X, that maintains
I have two tables which I want to join together using a left outer
I have an application that uses incident numbers (amongst other types of numbers). These
I have a C program that mines a huge data source (20GB of raw
I have a MySQL table called items that contains thousands of records. Each record

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.