-1
I have two tables, the first doesn’t matter for now, the second follows example below and we will name from table2:
id | column1 | column2 |
---|---|---|
1 | valor1 | value2 |
2 | value2 | valor1 |
3 | Valor3 | value4 |
4 | value5 | value6 |
And I have the following appointment:
SELECT * FROM tabela1
WHERE coluna1 IN (SELECT coluna1 FROM tabela2)
The point is, I’d like him to do that select between parentheses only when the same values exist, but in different columns that in the case would be only rows 1 and 2 of my example, the same values exist in the bottom row, but in different columns. Would it be possible? In the query I would like it to return the result below:
id | column1 | column2 |
---|---|---|
1 | valor1 | value2 |
2 | value2 | valor1 |
Henry, you tried to write everything so generic that it gets confusing. Either a result where the value of column1 exists in column2 in another row is that?
– Ricardo Pontual
I’m sorry if I couldn’t express myself very well, I’m starting now. That would be, however, to enter this condition the value of column 2 also needs to exist in column 1.
– Henry Victor