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

The Archive Base Latest Questions

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

I want to compare content of 15 columns in two rows. I am using

  • 0

I want to compare content of 15 columns in two rows.
I am using db2 9 with jdbc.
Can I use a sql to get a result like “match or not match”


And How can I get columns differs?

  • 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-20T22:00:41+00:00Added an answer on May 20, 2026 at 10:00 pm

    You can use the EXCEPT operator to do this.

    In the example below, I’m using common table expressions to fetch a the single rows (assuming, in this case, that id is the primary key.

    with r1 as (select c1, c2, ..., c15 from t where id = 1),
         r2 as (select c1, c2, ..., c15 from t where id = 2)
    select * from r1
    except 
    select * from r2
    

    If this returns 0 rows, then the rows are identical. If it returns a row, then the two rows differ.

    If you really want the result to be ‘MATCH’ or ‘NOT MATCH’:

    with r1 as (select c1, c2, ..., c15 from t where id = 1),
         r2 as (select c1, c2, ..., c15 from t where id = 2),
         rs as (select * from r1 except select * from r2)
    select
       case when count(*) = 0 then 'MATCH' 
            else 'NOT MATCH' 
            end as comparison 
    from
       rs;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to compare two strings for equality when either or both can be
I want to compare the content of two files in WinForms. Every file contains
So I've got a table called HoldingQueue and I want to compare two rows
Using Ruby 1.9.2 Problem Compare the content, not the results, of two procs. I
I want to get the contents from a row in the database and compare
I want to compare records between 2 databases on my SQL 2008 Server. The
I want to compare two CSV files to see if they are different. I
I am trying to compare two tables to find rows in each table that
I want to compare two XML files, they are the same as each other.
In a Unit Test (in Visual Studio 2008) I want to compare the content

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.