문제

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!

도움이 되었습니까?

해결책

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top