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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:11:57+00:00 2026-06-06T15:11:57+00:00

My table ANONYMOUS ONE TWO 1 2 2 1 1 2 3 1 Now

  • 0

My table

ANONYMOUS
ONE   TWO
1      2
2      1
1      2
3      1

Now i want to select distinct set of one and two.
My selected list should be

ANONYMOUS
    ONE   TWO
    1      2
    3      1
  • 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-06T15:11:59+00:00Added an answer on June 6, 2026 at 3:11 pm

    Your question isn’t very clear, but I guess you mean this:

    SELECT DISTINCT one, two
    FROM yourtable AS T1
    WHERE one <= two
    OR NOT EXISTS
    (
         SELECT *
         FROM yourtable AS T2
         WHERE T1.one = T2.two
         AND T1.two = T2.one
    )
    

    It finds rows with (one, two) where the reversed pair (two, one) does not exist. If both exist, it chooses the pair such that one < two. It also selects rows where the values are equal.

    See it working online: sqlfiddle

    If you would prefer to use a JOIN instead of NOT EXISTS you can do that:

    SELECT DISTINCT T1.one, T1.two
    FROM yourtable AS T1
    LEFT JOIN yourtable AS T2
    ON T1.one = T2.two
    AND T1.two = T2.one
    WHERE T1.one <= T1.two
    OR T2.one IS NULL
    

    See it working online: sqlfiddle

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

Sidebar

Related Questions

I have an set of structs that I want to store inside an anonymous
I have two tables in this project of mine. One table is for the
table user: |id|name|employee_priority_id|user_priority_id| table priority: |id|name| As you can see, there are two foreign
table id | word SELECT id FROM table WHERE word = hello OR word
I have table called Direccion other called Cliente each one defined like this public
In lua, one can very easily create a table and add functions to it.
I have 2 tables, and want to get records from 1 table and to
I am developing a PHP mini-framework, one of whose methods builds an HTML table
I have one table: drupal.comments , with amongst others, the columns: cid: primary key
I have an html table that is displaying customer orders. One of these columns

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.