Retrieving players involved in last hand of a session..

Forum for users that want to write their own custom queries against the PT database either via the Structured Query Language (SQL) or using the PT3 custom stats/reports interface.

Moderator: Moderators

Retrieving players involved in last hand of a session..

Postby maxp1981 » Fri Mar 07, 2008 10:15 am

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
maxp1981
 
Posts: 9
Joined: Thu Feb 28, 2008 11:54 am

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

Postby APerfect10 » Fri Mar 07, 2008 4:21 pm

[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
APerfect10
Site Admin
 
Posts: 4489
Joined: Sat Dec 08, 2007 6:03 pm

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

Postby maxp1981 » Fri Mar 07, 2008 6:47 pm

Thx !

Good old left join, already forgot that it exists...
maxp1981
 
Posts: 9
Joined: Thu Feb 28, 2008 11:54 am


Return to Custom Stats, Reports, and SQL [Read Only]

Who is online

Users browsing this forum: No registered users and 30 guests