1

I have a table like this -

tableCountry

  1. USA
  2. UK
  3. Germany

I want to write a query to list out the following combinations -

>USA-UK
>USA-Germany
>UK-USA
>UK-Germany
>Germany-USA
>Germany-UK

Is such a combination listing possible through postgresql?

Thanks.

1

1 Answer 1

2

This is as simple as:

SELECT t1.Country || '-' || t2.Country
  FROM table t1
  JOIN table t2 ON t1.Country <> t2.Country;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.