Selecting games which a given user can join

2001-01-31 Thread zbynek

Hi there!

I'm new to SQL and I can't figure out a query which would give me the result
I need. What I want to do is this:

I have table that stores names of players and number of the game they play
(one player can play more games concurrently). Other users can join the
game. For given user I want to display the games which he can join. The only
condition is that the user can't join any game which he already plays.

If I have this

+-+-+
| gid | user|
+-+-+
|   1 | jack|
|   1 | john|
|   1 | peter   |
|   1 | richard |
|   2 | john|
|   2 | richard |
|   3 | peter   |
|   4 | jack|
|   4 | peter   |
|   5 | peter   |
|   5 | john|
+-+-+

then for jack I want numbers 2, 3, 5 but not 4; for peter it should be 2 and
no other.

I'll appreciate your advice!

zbynek


-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: Selecting games which a given user can join

2001-01-31 Thread Beasley, Julien

That's what I would have suggested as well, but I tried that on a test table
and it returned all t2.id's in t2.


Julien Beasley
Bridge News Asia Applications Specialist

 -Original Message-
 From: Rus [SMTP:[EMAIL PROTECTED]]
 Sent: Thursday, February 01, 2001 10:26 AM
 To:   [EMAIL PROTECTED]
 Subject:  Re: Selecting games which a given user can join
 
 
 select t2.id from gamers t1,games t2 where t1.user="jack" and
 t2.idt1.gid
 group by t2.id
 
  Original Message -
 From: zbynek [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Wednesday, January 31, 2001 4:31 PM
 Subject: Selecting games which a given user can join
 
 
  Hi there!
 
  I'm new to SQL and I can't figure out a query which would give me the
 result
  I need. What I want to do is this:
 
  I have table that stores names of players and number of the game they
 play
  (one player can play more games concurrently). Other users can join the
  game. For given user I want to display the games which he can join. The
 only
  condition is that the user can't join any game which he already plays.
 
  If I have this
 
  +-+-+
  | gid | user|
  +-+-+
  |   1 | jack|
  |   1 | john|
  |   1 | peter   |
  |   1 | richard |
  |   2 | john|
  |   2 | richard |
  |   3 | peter   |
  |   4 | jack|
  |   4 | peter   |
  |   5 | peter   |
  |   5 | john|
  +-+-+
 
  then for jack I want numbers 2, 3, 5 but not 4; for peter it should be 2
 and
  no other.
 
  I'll appreciate your advice!
 
  zbynek
 
 
  -
  Before posting, please check:
 http://www.mysql.com/manual.php   (the manual)
 http://lists.mysql.com/   (the list archive)
 
  To request this thread, e-mail [EMAIL PROTECTED]
  To unsubscribe, e-mail
 [EMAIL PROTECTED]
  Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
 
 
 
 
 
 -
 Before posting, please check:
http://www.mysql.com/manual.php   (the manual)
http://lists.mysql.com/   (the list archive)
 
 To request this thread, e-mail [EMAIL PROTECTED]
 To unsubscribe, e-mail
 [EMAIL PROTECTED]
 Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail [EMAIL PROTECTED]
To unsubscribe, e-mail [EMAIL PROTECTED]
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php