Question

I need to find matching values in two columns in same table, but with different rows.

| id | b | c |

| 1 | 2 | 3 |

| 2 | 2 | 4 |

| 3 | 2 | 5 |

| 4 | 2 | 1 |

| 5 | 3 | 1 |

| 6 | 6 | 1 |

| 7 | 7 | 1 |

| 8 | 8 | 1 |


what i want is value 3 is in both columns

Please Help!

Was it helpful?

Solution

Try this self join:

SELECT DISTINCT t.b
FROM your_table t
INNER JOIN your_table s
ON t.b = s.c
AND t.id <> s.id
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top