[PHP-DB] Need help with a tricky query

2005-05-19 Thread Andy Green
I'm trying to write a query that pulls details on a game record, as well as
the officials assigned to the game (up to 4 officials may be assigned to
each game, but that's not always the case).

Game details are in the games table, and assignments are in the
games_referees table (which I alias as referee,ar1,ar2, and fourth).  

Ultimately, I want all the games for a given date, and the referees assigned
to them.  Below is the query I'm working with so far.  In its current state,
it returns results only when a full crew is assigned to the game (referee,
ar1,ar2, fourth).  The query is below:

SELECT g. * , concat( ref.fname,  ' ', ref.lname )  AS ref, concat(
ar1.fname,  ' ', ar1.lname )  AS ar1, concat( ar2.fname,  ' ', ar2.lname )
AS ar2, concat( fourth.fname,  ' ', fourth.lname )  AS fourth
FROM ( ( ( ( ( ( ( ( games g
RIGHT  OUTER  JOIN games_referees ref_ass ON ( g.id = ref_ass.gnum )  )
RIGHT  OUTER  JOIN people ref ON ( ref.login = ref_ass.referee )  )
RIGHT  OUTER  JOIN games_referees ar1_ass ON ( g.id = ar1_ass.gnum )  )
RIGHT  OUTER  JOIN people ar1 ON ( ar1.login = ar1_ass.referee )  )
RIGHT  OUTER  JOIN games_referees ar2_ass ON ( g.id = ar2_ass.gnum )  )
RIGHT  OUTER  JOIN people ar2 ON ( ar2.login = ar2_ass.referee )  )
RIGHT  OUTER  JOIN games_referees fourth_ass ON ( g.id = fourth_ass.gnum )
)
RIGHT  OUTER  JOIN people fourth ON ( fourth.login = fourth_ass.referee )  )
WHERE ref_ass.position =1 AND ar1_ass.position =2 AND ar2_ass.position =3
AND fourth_ass.position =4 AND g.date =  '2004-09-25'

Any help would be greatly appreciated.

Thank

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP-DB] MySQL query failing on apostrophe in data

2003-08-27 Thread Andy Green
try putting a \ before the apostrophe

-Original Message-
From: Dillon, John [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 27, 2003 12:59 PM
To: 'PHP-DB'
Subject: [PHP-DB] MySQL query failing on apostrophe in data


How do I avoid the problem in the subject hereto?  SELECT query uses
variable in the WHERE clause.  Fails on the following query:

SELECT Tbl.fld FROM Tbl WHERE Tbl.fld2='11301201 0603A HKA 3902 #3708_JD's
AE Exp' AND ...

John











































   http://www.cantor.com
CONFIDENTIAL: This e-mail, including its contents and attachments, if any,
are confidential. If you are not the named recipient please notify the
sender and immediately delete it. You may not disseminate, distribute, or
forward this e-mail message or disclose its contents to anybody else.
Copyright and any other intellectual property rights in its contents are the
sole property of Cantor Fitzgerald.
 E-mail transmission cannot be guaranteed to be secure or error-free.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message which arise as a result of e-mail
transmission.  If verification is required please request a hard-copy
version.
 Although we routinely screen for viruses, addressees should check this
e-mail and any attachments for viruses. We make no representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that to ensure regulatory compliance and for the protection of
our customers and business, we may monitor and read e-mails sent to and from
our server(s).

For further important information, please read the  Important Legal
Information and Legal Statement at
http://www.cantor.com/legal_information.html

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php