phpMyAdmin
 sql >> Datenbank >  >> Database Tools >> phpMyAdmin

Bedingte Auswahl der MYSQL-Spalte

Ich denke, Sie können case when then verwenden Syntax wie folgt:

SELECT CASE WHEN player1id = 1 THEN player2id ELSE player1id  END
FROM players WHERE player1id =1 OR player2id=1;

Alternativ:

SELECT CASE WHEN player1id = 1 THEN player2id WHEN player2id =1 THEN player1id  END
FROM players WHERE player1id =1 OR player2id=1;