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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T14:16:49+00:00 2026-05-30T14:16:49+00:00

I have a table with the following columns: a|b|c|d|e and I want to select

  • 0

I have a table with the following columns:

a|b|c|d|e

and I want to select all the records such that a combination of a subset of the columns is repeated (say, a, b, c). Example:

a|b|c|d|e
1|2|3|1|2
6|7|8|9|1
1|2|3|4|5
1|2|2|5|4

should result in:

1|2|3|1|2
1|2|3|4|5
  • 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-30T14:16:51+00:00Added an answer on May 30, 2026 at 2:16 pm

    This will do it:

    SELECT a,b,c,d,e
      FROM t t1
     WHERE EXISTS ( SELECT NULL
                      FROM t t2
                     WHERE t1.a = t2.a AND t1.b = t2.b AND t1.c = t2.c
                       AND t1.rowid <> t2.rowid
                  )
    

    A second way (SQLite does not support (x,y) in (select two columns)):

    SELECT a,b,c,d,e
      FROM t
     WHERE quote(a)||','||quote(b)||','||quote(c)
        IN ( SELECT quote(a)||','||quote(b)||','||quote(c)
               FROM t
              GROUP BY a,b,c
             HAVING COUNT(*) > 1
           )
    

    A third way:

    SELECT a,b,c,d,e
      FROM ( SELECT a,b,c
               FROM t
              GROUP BY a,b,c
             HAVING COUNT(*) > 1
           )
    NATURAL JOIN t
    

    Capture

    This last one has an advantage, you can also add aggregate rows (like if you used analytic functions in other RDBMS:)

    sqlite> .headers on
    sqlite> .mode column
    sqlite> .width 3 3 3 3 3 20
    sqlite> SELECT a,b,c,d,e,"Rows in this group"
       ...>   FROM ( SELECT a,b,c
       ...>               , COUNT(*) AS "Rows in this group"
       ...>            FROM t
       ...>           GROUP BY a,b,c
       ...>          HAVING COUNT(*) > 1
       ...>        )
       ...> NATURAL JOIN t;
    a    b    c    d    e    Rows in this group
    ---  ---  ---  ---  ---  --------------------
    1    2    3    1    2    2
    1    2    3    4    5    2
    

    which is similar to this in Oracle:

       WITH x AS
          (SELECT a,b,c,d,e,COUNT(*) OVER (PARTITION BY a,b,c) "Rows in this group"
             FROM t
          )
       SELECT * FROM x WHERE "Rows in this group" >= 2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a data.table and I want to select all the rows
I have a table with the following columns: EntityId, EntityName, EntityProfile, ................. I want
Lets say I have table with following columns 1. Client - string. 2. Profit
Lets say I have a table with the following columns: Qty, INTEGER SaleDate, DATETIME
I have a table that contains the following columns: ID int, DISTANCE float, EVENT
I have a table with about 1000 records and 2000 columns. What I want
I have a table which contains the following columns: UniqueID remote_ip_addr platform I want
I have a table called activity that uses the following columns: LoginDate, LoginID, Department,
What I have is a table with the following columns All columns are nvarchar
I have mysql table with the following structure. All records are static and only

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.