Page 1 of 1

Retrieving players involved in last hand of a session..

PostPosted: Fri Mar 07, 2008 10:15 am
by maxp1981
I need to know which players were involved in the last hand of a given session.

In the moment im doing it this way:

[codemhj]
SELECT hhps.id_hand, hhps.date_played, hhps.id_player, hhpd.seat FROM holdem_hand_summary hhs, holdem_hand_player_statistics hhps , oldem_hand_player_detail hhpd
WHERE hhps.id_hand = hhs.id_hand and hhpd.id_hand = hhs.id_hand and hhpd.id_player= hhps.id_player AND hhps.id_hand in
(SELECT hhps.id_hand FROM holdem_hand_summary hhs, holdem_hand_player_statistics hhps WHERE hhps.id_hand = hhs.id_hand AND hhps.id_session =6931) order by hhps.date_played desc, hhps.id_hand desc limit 10[/codemhj]

Then run through those hands and while the handno keeps the same i grab the player_id, but I guess there is a better way...I just couldnt figure it out...

If I only needed the id I could use DISTINCT, but I also need the seat no., so this isnt possible

Re: Retrieving players involved in last hand of a session..

PostPosted: Fri Mar 07, 2008 4:21 pm
by APerfect10
[code5tg]SELECT
hhps.id_hand,
hhps.date_played,
hhps.id_player,
hhpd.seat

FROM
holdem_hand_player_statistics hhps
LEFT JOIN holdem_hand_player_detail hhpd using (id_hand, id_player)

WHERE
hhps.id_hand = (
SELECT
MAX(id_hand)

FROM
holdem_hand_player_statistics

WHERE
id_session = '{ID_SESSION}'
);[/code5tg]

Best regards,

Derek

Re: Retrieving players involved in last hand of a session..

PostPosted: Fri Mar 07, 2008 6:47 pm
by maxp1981
Thx !

Good old left join, already forgot that it exists...