Faire une requête SQL

Résolu/Fermé
Sarah - Modifié le 2 oct. 2018 à 13:36
 Sarah - 2 oct. 2018 à 15:52
TABLE
| ID | P1 | P2 |
| A | 1 | 2 |
| B | 1 | 2 |
| C | 1 | 2 |
| C | 2 | 1 |
| C | 1 | 3 |

Code à convertir en SQL :
For (int i=0; i<Count.line; i++)
{
For (int j=0; j<Count.line; j++)
{
If (line[i].ID = line[j].ID && line[i].P1 = line[j].P2 && line[i].P2 = line[j].P1)
{
Show(line[i]);
}
}
}

Comment faire ce code ???
SELECT *
FROM TABLE...

Voici se que je souhaite obtenir en résultat :
| C | 1 | 2 |
| C | 2 | 1 |

Merci à vous la communauté !

2 réponses

yg_be Messages postés 22698 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 18 avril 2024 1 471
2 oct. 2018 à 14:22
bonjour, moi j'essayerais:
select t1.* 
from table as t1, table as t2
where 
t1.ID = t2.ID and t1.P1 = t2.P2 and t1.P2 = t2.P1
1
Merci pour ta réponse yg_be, cela m'a permis de trouver !
0