SQL Query JOIN question

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

SQL Query JOIN question

Postby js2002 » Wed Oct 06, 2010 10:22 am

SELECT holdem_hand_summary.id_hand, holdem_hand_summary.id_site, holdem_hand_summary.date_played,holdem_hand_player_statistics.amt_won
FROM holdem_hand_summary,holdem_hand_player_statistics
WHERE flg_note= true
ORDER BY date_played
DESC Limit 50 offset 0

Which filter (/where...) does work on table holdem_hand_player_statistics?
The goal was to get the ids form the first table and get only these from the second table. So that the id is a condition for the 2nd table.

like this: "get * from holdem_hand_player_statistics WHERE holdem_hand_summary.id_hand = <here the first SELECT blablabla to get the ids from first table>"

is the SQL Query above the correct syntax for this semantics?

EDIT:

BETTER:

SELECT holdem_hand_summary.id_hand,holdem_hand_player_statistics.id_hand, holdem_hand_summary.id_site, holdem_hand_summary.date_played,
holdem_hand_player_statistics.amt_won
FROM holdem_hand_summary,holdem_hand_player_statistics
WHERE flg_note = true AND holdem_hand_summary.id_hand = holdem_hand_player_statistics.id_hand
ORDER BY date_played
DESC Limit 50 offset 0
js2002
 
Posts: 1502
Joined: Fri Feb 15, 2008 5:44 am
Location: Germany

Re: SQL Query JOIN question

Postby kraada » Wed Oct 06, 2010 12:20 pm

The edit is better, you only need to specify one id_hand in the output though because they will always be identical to one another (due to your WHERE clause).
kraada
Moderator
 
Posts: 54430
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: SQL Query JOIN question

Postby js2002 » Wed Oct 06, 2010 1:00 pm

yeah, it is just a testing SQL for the PT3 Exporter (with Stats) tool
js2002
 
Posts: 1502
Joined: Fri Feb 15, 2008 5:44 am
Location: Germany


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

Who is online

Users browsing this forum: No registered users and 0 guests