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 :

Vérifier si un joueur a cliqué partout ?


Sujet :

Requêtes MySQL

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Webmarketer
    Inscrit en
    Novembre 2015
    Messages
    22
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Drôme (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmarketer

    Informations forums :
    Inscription : Novembre 2015
    Messages : 22
    Points : 28
    Points
    28
    Par défaut Vérifier si un joueur a cliqué partout ?
    Bonjour,

    désolé pour le titre, mais je ne voyais pas comment expliquer cette requête !

    J'ai une table JOUEUR(id) , une table CLICK(id) , et une table JOUEUR_CLICK(id_joueur, id_click)

    La table Click peut avoir 10 éléments. Pour gagner, le joueur doit avoir clické sur TOUS les éléments.

    Il me faut une requête qui me dise si pour un joueur donné, tous les éléments ont été cliqués, je ne vois pas du tout comment faire ?

    Merci de votre aide !

  2. #2
    Rédacteur

    Avatar de SQLpro
    Homme Profil pro
    Expert bases de données / SQL / MS SQL Server / Postgresql
    Inscrit en
    Mai 2002
    Messages
    21 774
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Var (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Expert bases de données / SQL / MS SQL Server / Postgresql
    Secteur : Conseil

    Informations forums :
    Inscription : Mai 2002
    Messages : 21 774
    Points : 52 746
    Points
    52 746
    Billets dans le blog
    5
    Par défaut
    Il suffit de faire une division relationnelle...

    À me lire : http://sqlpro.developpez.com/cours/divrelationnelle/

    Et pour en savoir plus et apprendre SQL :
    Nom : Couverture SQL Synthex 4e ed - 500.jpg
Affichages : 72
Taille : 77,8 Ko

    A +
    Frédéric Brouard - SQLpro - ARCHITECTE DE DONNÉES - expert SGBDR et langage SQL
    Le site sur les SGBD relationnels et le langage SQL: http://sqlpro.developpez.com/
    Blog SQL, SQL Server, SGBDR : http://blog.developpez.com/sqlpro
    Expert Microsoft SQL Server - M.V.P. (Most valuable Professional) MS Corp.
    Entreprise SQL SPOT : modélisation, conseils, audit, optimisation, formation...
    * * * * * Expertise SQL Server : http://mssqlserver.fr/ * * * * *

  3. #3
    Expert éminent sénior Avatar de Artemus24
    Homme Profil pro
    Agent secret au service du président Ulysses S. Grant !
    Inscrit en
    Février 2011
    Messages
    6 381
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Agent secret au service du président Ulysses S. Grant !
    Secteur : Finance

    Informations forums :
    Inscription : Février 2011
    Messages : 6 381
    Points : 19 066
    Points
    19 066
    Par défaut
    Salut zoocoral.

    La dernière requête de cet exemple correspond à ta demande.
    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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    --------------
    SET AUTOCOMMIT = 0
    --------------
     
    --------------
    START TRANSACTION
    --------------
     
    --------------
    DROP DATABASE IF EXISTS `base`
    --------------
     
    --------------
    CREATE DATABASE `base`
            DEFAULT CHARACTER SET `latin1`
            DEFAULT COLLATE       `latin1_general_ci`
    --------------
     
    --------------
    DROP TABLE IF EXISTS `joueur`
    --------------
     
    --------------
    CREATE TABLE `joueur`
    ( `id`      integer unsigned  NOT NULL AUTO_INCREMENT primary key,
      `nom`     varchar(255)      NOT NULL
    ) ENGINE=InnoDB
      DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
      ROW_FORMAT=COMPRESSED
    --------------
     
    --------------
    INSERT INTO `joueur` (`nom`) VALUES
      ('albert'),('bertrand'),('charles'),('denis'),('eric'),('fabien'),('gaston'),('henri')
    --------------
     
    --------------
    select * from joueur
    --------------
     
    +----+----------+
    | id | nom      |
    +----+----------+
    |  1 | albert   |
    |  2 | bertrand |
    |  3 | charles  |
    |  4 | denis    |
    |  5 | eric     |
    |  6 | fabien   |
    |  7 | gaston   |
    |  8 | henri    |
    +----+----------+
    --------------
    DROP TABLE IF EXISTS `poste`
    --------------
     
    --------------
    CREATE TABLE `poste`
    ( `id`        integer unsigned  NOT NULL AUTO_INCREMENT primary key,
      `rubrique`  varchar(255)      NOT NULL
    ) ENGINE=InnoDB
      DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
      ROW_FORMAT=COMPRESSED
    --------------
     
    --------------
    INSERT INTO `poste` (`rubrique`) VALUES
      ('un'),('deux'),('trois'),('quatre'),('cinq')
    --------------
     
    --------------
    select * from poste
    --------------
     
    +----+----------+
    | id | rubrique |
    +----+----------+
    |  1 | un       |
    |  2 | deux     |
    |  3 | trois    |
    |  4 | quatre   |
    |  5 | cinq     |
    +----+----------+
    --------------
    DROP TABLE IF EXISTS `rencontre`
    --------------
     
    --------------
    CREATE TABLE `rencontre`
    ( `id`         integer unsigned  NOT NULL AUTO_INCREMENT primary key,
      `id_joueur`  integer unsigned  NOT NULL,
      `id_poste`   integer unsigned  NOT NULL,
      `score`      integer           NOT NULL,
      CONSTRAINT    `FK_01` FOREIGN KEY (`id_joueur`) REFERENCES `joueur` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
      CONSTRAINT    `FK_02` FOREIGN KEY (`id_poste`)  REFERENCES `poste`  (`id`) ON DELETE RESTRICT ON UPDATE CASCADE,
      unique index  `idx`  (`id_joueur`,`id_poste`)
    ) ENGINE=InnoDB
      DEFAULT CHARSET=`latin1` COLLATE=`latin1_general_ci`
      ROW_FORMAT=COMPRESSED
    --------------
     
    --------------
    INSERT INTO `rencontre` (`id_joueur`,`id_poste`,`score`) VALUES
      (1, 1, +3), (1, 2, -3), (1, 3, +2), (1, 4, +1), (1, 5, -3),
      (2, 1, +1), (2, 2, -1), (2, 3, -2), (2, 4, +1),
      (3, 1, +1), (3, 2, +1), (3, 4, -2),
      (4, 1, -3), (4, 2, -3),
      (5, 1, -1), (5, 3, +2),
      (6, 1, +2), (6, 2, +2), (6, 3, +1), (6, 4, -3), (6, 5, -2),
      (7, 1, +3), (7, 3, -1),
      (8, 1, +1), (8, 4, -1)
    --------------
     
    --------------
    select * from rencontre
    --------------
     
    +----+-----------+----------+-------+
    | id | id_joueur | id_poste | score |
    +----+-----------+----------+-------+
    |  1 |         1 |        1 |     3 |
    |  2 |         1 |        2 |    -3 |
    |  3 |         1 |        3 |     2 |
    |  4 |         1 |        4 |     1 |
    |  5 |         1 |        5 |    -3 |
    |  6 |         2 |        1 |     1 |
    |  7 |         2 |        2 |    -1 |
    |  8 |         2 |        3 |    -2 |
    |  9 |         2 |        4 |     1 |
    | 10 |         3 |        1 |     1 |
    | 11 |         3 |        2 |     1 |
    | 12 |         3 |        4 |    -2 |
    | 13 |         4 |        1 |    -3 |
    | 14 |         4 |        2 |    -3 |
    | 15 |         5 |        1 |    -1 |
    | 16 |         5 |        3 |     2 |
    | 17 |         6 |        1 |     2 |
    | 18 |         6 |        2 |     2 |
    | 19 |         6 |        3 |     1 |
    | 20 |         6 |        4 |    -3 |
    | 21 |         6 |        5 |    -2 |
    | 22 |         7 |        1 |     3 |
    | 23 |         7 |        3 |    -1 |
    | 24 |         8 |        1 |     1 |
    | 25 |         8 |        4 |    -1 |
    +----+-----------+----------+-------+
    --------------
    select j.nom, p.rubrique, r.score
    from       rencontre as r
     
    inner join poste     as p
    on p.id = r.id_poste
     
    inner join joueur    as j
    on j.id = r.id_joueur
     
    order by j.nom, p.rubrique
    --------------
     
    +----------+----------+-------+
    | nom      | rubrique | score |
    +----------+----------+-------+
    | albert   | cinq     |    -3 |
    | albert   | deux     |    -3 |
    | albert   | quatre   |     1 |
    | albert   | trois    |     2 |
    | albert   | un       |     3 |
    | bertrand | deux     |    -1 |
    | bertrand | quatre   |     1 |
    | bertrand | trois    |    -2 |
    | bertrand | un       |     1 |
    | charles  | deux     |     1 |
    | charles  | quatre   |    -2 |
    | charles  | un       |     1 |
    | denis    | deux     |    -3 |
    | denis    | un       |    -3 |
    | eric     | trois    |     2 |
    | eric     | un       |    -1 |
    | fabien   | cinq     |    -2 |
    | fabien   | deux     |     2 |
    | fabien   | quatre   |    -3 |
    | fabien   | trois    |     1 |
    | fabien   | un       |     2 |
    | gaston   | trois    |    -1 |
    | gaston   | un       |     3 |
    | henri    | quatre   |    -1 |
    | henri    | un       |     1 |
    +----------+----------+-------+
    --------------
    select j.nom
    from       joueur    as j
    inner join rencontre as r
    on r.id_joueur = j.id
    group by j.nom
    having count(distinct r.id_poste) = ( select count(*) from poste)
    --------------
     
    +--------+
    | nom    |
    +--------+
    | albert |
    | fabien |
    +--------+
    --------------
    COMMIT
    --------------
     
    --------------
    SET AUTOCOMMIT = 1
    --------------
     
     
    Appuyez sur une touche pour continuer...
    @+
    Si vous êtes de mon aide, vous pouvez cliquer sur .
    Mon site : http://www.jcz.fr

Discussions similaires

  1. Comment vérifier qu'un PC de joueur répond à vos exigences
    Par LittleWhite dans le forum Développement 2D, 3D et Jeux
    Réponses: 3
    Dernier message: 24/08/2015, 18h19
  2. [Débutant] Vérifier si un bouton est cliqué ou non
    Par amina-info dans le forum VB.NET
    Réponses: 6
    Dernier message: 31/03/2014, 12h02
  3. Réponses: 5
    Dernier message: 21/02/2014, 09h16
  4. Vérifier si on clique sur un bouton ?
    Par jeremygata dans le forum Langage
    Réponses: 4
    Dernier message: 27/11/2008, 13h54
  5. Réponses: 3
    Dernier message: 12/04/2006, 13h57

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