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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T17:18:04+00:00 2026-06-08T17:18:04+00:00

I have two columns, source and destination in table Hyperlink, to store the source

  • 0

I have two columns, source and destination in table Hyperlink, to store the source and destination of hyperlinks.

source | destination 
-------------------- 
  a    |  b 
  b    |  c 
  c    |  d 
  c    |  b 

There are two hyperlinks involving both b and c. The difference between the two hyperlinks is the direction of the hyperlink. However, my objective is to retrieve unique hyperlinks, no matter which direction. So for hyperlinks such as from b to c and from c to b, I just want to select one of them. Any one would do.

So my results should look like this:

source | destination 
-------------------- 
  a    |  b 
  b    |  c 
  c    |  d 

So far I am able to implement this in Java, with some processing before I execute SQL statements using JDBC. However, this is going to be very tedious when the table becomes very large.

I wonder if there is anyway I can do this in SQL instead.

I tried SELECT DISTINCT source,destination FROM Hyperlink but it returns me the unique permutations. I need the unique combinations.

Thanks!

  • 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-08T17:18:05+00:00Added an answer on June 8, 2026 at 5:18 pm

    This is easily achievable with the least() and greatest() operator, but as MySQL doesn’t support them you need to use a CASE construct to get the smaller/greater one. With two columns this is ok, but this solution gets pretty messy once more columns are involved

    select distinct 
              case 
                when source < destination then source 
                else destination 
              end as source,
              case 
                when source > destination then source 
                else destination 
              end as destination
    from hyperlinks
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables, both with the same columns. The first table contains original
I have two tables [Source: table1, Destination:table2] with 3 columns each (checkbox, value1, value2).
I have two columns in my table and the rows are created dynamically. <table
I have two columns(column1, column2) in my oracle database table named as demo .
I have two GridViews. One is Source GridView and another one is Destination GridView.
I have two tables a source and a destination. I want to flag the
I have two columns (A and B) in a table: column_A column_B 10 alb
I have a table that holds only two columns - a ListID and PersonID.
I have two tables: a source table and a target table. The target table
I have an NSTableView with two columns and a data source that fills it

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.