Is there any place where can I find sample queries (SELECT, UPDATE, DELETE) for Sean Lahman database? I wanna see what can be done with this database..
I use to ship the database with sample queries. Maybe I should revisit that idea. Here are a few to get you started.
A simple one to show all of the players named "Sean:"
SELECT nameLast, nameFirst, debut
FROM Master
WHERE (nameFirst="Sean")
ORDER BY nameLast;
Here's one to show a list of players with 50 HRs in a season:
SELECT Master.nameLast, Master.nameFirst, Batting.HR, Batting.yearID
FROM Batting INNER JOIN Master ON Batting.playerID = Master.playerID
WHERE (((Batting.HR)>=50))
ORDER BY Batting.HR DESC;
Here's one to show the all-time leaders in strikeouts:
SELECT Master.nameLast, Master.nameFirst, Sum(Pitching.SO) AS SumOfSO
FROM Pitching INNER JOIN Master ON Pitching.playerID = Master.playerID
GROUP BY Pitching.playerID, Master.nameLast, Master.nameFirst
ORDER BY Master.nameLast;
There are several websites with tutorials on using the database that include sample queries. See: http://webdev.cas.msu.edu/cas992/weeks/week5.html http://www.hardballtimes.com/main/article/databases-for-sabermetricians-part-one/
You can find more by googling 'sql lahman'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With