PDA

View Full Version : SQL query HELP, hero in BB and villain steals



Rattanat
11-18-2010, 12:53 AM
How to make a query, which returns all pokerhand_ids and holehards where specific villain steals and hero is a bigblind?

Have think this several hours now, I'm so noob in SQL :confused:

redlotus
11-18-2010, 12:14 PM
Give this one a try:

WITH hero_bb AS
(SELECT pokerhand_id, player_id FROM playerhandscashkeycolumns_hero JOIN playerhandscashmisc_hero USING (playerhand_id) WHERE positiontype_id=1 AND bbstealattempted=true),
villain_steal AS
(SELECT pokerhand_id, player_id FROM playerhandscashkeycolumns WHERE player_id=(SELECT player_id FROM players WHERE playername='villain') AND positiontype_id in (0,5,4) AND preflopaction_id=0 AND firstpreflopactiontype_id=3)
SELECT pokerhand_id, (SELECT holecardstring FROM holecards WHERE holecard_id=holecardvalue_id)
FROM playerhandscashkeycolumns
WHERE pokerhand_id in (SELECT pokerhand_id FROM hero_bb)
AND pokerhand_id in (SELECT pokerhand_id FROM villain_steal)
AND (player_id in (SELECT player_id FROM hero_bb) OR player_id in (SELECT player_id FROM villain_steal))
Just change "villain" to the name of the villain you are interested in.

-red

Rattanat
11-18-2010, 11:36 PM
just what i ment, THANKS