Jump to content

JohnJSal

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

JohnJSal's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [quote author=AndyB link=topic=106273.msg424797#msg424797 date=1156953145] SELECT playerID, RBI from Batting WHERE yearID = '2005' ORDER by RBI DESC LIMIT 1 [/quote] Hmm, interesting! I guess I was on the wrong track with max(RBI). Thanks!
  2. Hi everyone. I have a question which seems like it should be painfully easy to answer, but I can't figure it out. I've tried several different queries, and they either return too much information, or they don't work. Here's the situation: I'm using a baseball database and am working with a single table called Batting. What I'd like to do is display the playerID and RBI columns for the player with the most RBIs in the 2005 (yearID). I've tried combinations of max(RBI) and playerID, but then I have to use a GROUP BY clause, which displays more than I want. So I'm hoping someone can help me. This seems like a very basic thing to do, but I'm having trouble working with a 'normal' column like playerID and an aggregate like max(RBI). Thanks, John
  3. Hi everyone. I'm fairly comfortable with the basics of MySQL, but I'm a little stumped on how to join three tables. First off, let me explain the table structures (from a baseball database): Master | playerID, nameFirst, nameLast Schools | schoolID, schoolName SchoolsPlayers | playerID, schoolID So the first name in each row is the table name (Master, etc.) and the following names are entries in that table. What I'd like to do is write  a query that will display a player's name and the school he went to. This is what I've come up with so far, but I don't know if it works yet because my script isn't working properly (a separate issue). select Master.nameFirst, Master.nameLast, Schools.schoolName from Master, Schools, SchoolsPlayers where Master.playerID = SchoolsPlayers.playerID and Schools.schoolID = SchoolsPlayers.schoolID I did a little searching and came across the use of a left or right join as another way to work with more than two tables, but I've never used that before, so I don't know if it's necessary or how it works. It seems like a join is what I need, which the above is not, and I'd like to learn how to write one that uses three (or more) tables. (I can handle two!) Thanks! John Quick note: This does work, but is it better to use joins in a case like this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.