1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| $query = "
SELECT
IF (lat1<>lng1 = 0, 'couple1',
IF (lat2<>lng2 = 0, 'couple2',
IF (lat3<>lng3 = 0, 'couple3',
IF (lat4<>lng4 = 0, 'couple4',
IF (lat5<>lng5 = 0, 'couple5',
IF (lat6<>lng6 = 0, 'couple6',
IF (lat7<>lng7 = 0, 'couple7',
IF (lat8<>lng8 = 0, 'couple8',
IF (lat9<>lng9 = 0, 'couple9',
IF (lat10<>lng10 = 0, 'couple10',false
)))))))))) AS colonne
FROM membre
WHERE id = :id";
$req = $bdd->prepare($query);
$req->bindParam(':id', $id, PDO::PARAM_INT);
$req->execute();
echo ($quelleColonne = $req->fetchColumn()); // donne par exemple couple4 si lat4 ET lng4 sont = à 0 |
Partager