IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Requêtes MySQL Discussion :

#1241 - Operand should contain 1 column(s)


Sujet :

Requêtes MySQL

  1. #1
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Octobre 2007
    Messages : 12
    Points : 7
    Points
    7
    Par défaut #1241 - Operand should contain 1 column(s)
    la requête SQL en dessous me génére l'erreuer suivante :#1241 - Operand should contain 1 column(s). Merci de m'aider à trouver une solution.

    reqûte "
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    CREATE OR REPLACE VIEW `own_adequat`.`vavertissementr62r64` (TR_PGID, TR_ID, SEARCHMILDIOU, SEARCHOIDIUM) AS
    SELECT
    TRAITEMENT.TR_PGID,
    TRAITEMENT.TR_ID,
    SUM(IF(STRCMP(PHRASE_RISQUE.RP_PHRASE,'R 62'),1,0) && (STRCMP(PHRASE_RISQUE.RP_PHRASE,'R 64'),2,0)) as SearchMildiou,
    0 as SearchOidium
    from
    PRODUIT_RISQUE,
    PHRASE_RISQUE,
    TRAITEMENT
    Where PRODUIT_RISQUE.PD_ID=TRAITEMENT.TR_PDMILDIOU
    and PRODUIT_RISQUE.RP_ID=PHRASE_RISQUE.RP_ID
    and (PHRASE_RISQUE.RP_PHRASE= 'R 62' OR PHRASE_RISQUE.RP_PHRASE= 'R 64')
    GROUP BY TRAITEMENT.TR_PGID, TRAITEMENT.TR_ID, TRAITEMENT.TR_PDMILDIOU, TRAITEMENT.TR_PDOIDIUM
    UNION
    SELECT
    TRAITEMENT.TR_PGID,
    TRAITEMENT.TR_ID,
    0 as SearchMildiou,
    SUM(IF(STRCMP(PHRASE_RISQUE.RP_PHRASE,'R 62'),1,0)&& (STRCMP(PHRASE_RISQUE.RP_PHRASE,'R 64'),2,0)) as SearchOidium
    from
    PRODUIT_RISQUE,PHRASE_RISQUE,TRAITEMENT
    where
    PRODUIT_RISQUE.RP_ID=PHRASE_RISQUE.RP_ID
    and PRODUIT_RISQUE.PD_ID=TRAITEMENT.TR_PDOIDIUM
    and (PHRASE_RISQUE.RP_PHRASE='R 62' OR PHRASE_RISQUE.RP_PHRASE='R 64')
    GROUP BY TRAITEMENT.TR_PGID,TRAITEMENT.TR_ID,TRAITEMENT.TR_PDMILDIOU,TRAITEMENT.TR_PDOIDIUM;"

  2. #2
    Membre expert
    Avatar de Maljuna Kris
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2005
    Messages
    2 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 613
    Points : 3 950
    Points
    3 950
    Par défaut
    Saluton,
    Problème de parenthèses qui font que les fonctions IF() n'ont qu'un seul opérande.

  3. #3
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Octobre 2007
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    Pouvez vous être plus explicite car je ne vois pas encore l'erreur merci

  4. #4
    Membre expert
    Avatar de Maljuna Kris
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2005
    Messages
    2 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 613
    Points : 3 950
    Points
    3 950
    Par défaut
    La syntaxe de la fonction IF
    IF(expr1,expr2,expr3)
    Or dans le code (probablement en raison des && qu'il vaudrait au demeurant mieux remplacer par des AND) on a IF(expr1)

  5. #5
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Octobre 2007
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    En fait le pb est le suivant :
    je dois comparer PHRASE_RISQUE.RP_PHRASE à 'R 62', ceci retournera 1 si le test est positif et 0 dans le cas contraire.
    je dois également comparer PHRASE_RISQUE.RP_PHRASE à 'R 64', ceci retournera 2 si le test est positif et 0 dans le cas contraire.
    ensuite je ft la somme.
    l'expression en oracle est la suivante: SUM(decode(PHRASE_RISQUE.RP_PHRASE,'R 62',1,'R 64',2,0)) .
    Mais en mysql je n'arrive pas à la faire.
    Merci de votre aide.

  6. #6
    Membre expert
    Avatar de Maljuna Kris
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2005
    Messages
    2 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 613
    Points : 3 950
    Points
    3 950
    Par défaut
    SUM(IF(PHRASE_RISQUE.RP_PHRASE='R 62',1,IF(PHRASE_RISQUE.RP_PHRASE='R 64',2,0))) .

  7. #7
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Octobre 2007
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    est ce que if peut supporter plus que trois paramètres (expressions) comme en oracle. Je cherche sur le web je ne trouve pas la réponse.

  8. #8
    Futur Membre du Club
    Profil pro
    Inscrit en
    Octobre 2007
    Messages
    12
    Détails du profil
    Informations personnelles :
    Localisation : Canada

    Informations forums :
    Inscription : Octobre 2007
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    merci Maljuna Kris c bon ça marche

  9. #9
    Membre expert
    Avatar de Maljuna Kris
    Homme Profil pro
    Retraité
    Inscrit en
    Novembre 2005
    Messages
    2 613
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 72
    Localisation : France, Finistère (Bretagne)

    Informations professionnelles :
    Activité : Retraité
    Secteur : Administration - Collectivité locale

    Informations forums :
    Inscription : Novembre 2005
    Messages : 2 613
    Points : 3 950
    Points
    3 950
    Par défaut
    Ne dankinde.

    par contre il faudrait marquer le post comme [RESOLU]

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 16/05/2015, 16h24
  2. Réponses: 0
    Dernier message: 21/04/2011, 20h47
  3. Réponses: 2
    Dernier message: 29/01/2010, 08h50
  4. #1241 - Operand should contain 1 column(s)
    Par Mister Paul dans le forum Requêtes
    Réponses: 5
    Dernier message: 12/11/2008, 15h59
  5. pb requete, reponse=Operand should contain 1 column(s)
    Par akara dans le forum Requêtes
    Réponses: 4
    Dernier message: 05/06/2007, 21h14

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo