solucion con codigo para sql server:
Código SQL:
Ver originalCREATE TABLE #temp
(
id INT IDENTITY(1,1),
id_entrada1 INT,
id_entrada2 INT
)
INSERT INTO #temp VALUES (9,7)
INSERT INTO #temp VALUES (9,5)
INSERT INTO #temp VALUES (2,9)
INSERT INTO #temp VALUES (9,10)
SELECT * FROM(
SELECT CASE WHEN id_entrada1=9 THEN id_entrada2 END AS VALUE FROM #temp
UNION
SELECT CASE WHEN id_entrada2=9 THEN id_entrada1 END AS VALUE FROM #temp
) AS t1 WHERE VALUE IS NOT NULL
Resultado:
value
2
5
7
10