title: mysql return multiple results with group by
body: <p>Please note this is regarding a homework problem, the homework is done and works to the spec, but it's slow so I'm trying to lessen how many SQL calls I make. And I'm still learning my SQL-fu.</p>
  
  <p>My table looks like:</p>
  
  <pre><code>Ticker |Name                  |Industry
  A      |Agilent Technologies  |Information Technology
  AA     |Alcoa Inc             |Materials
  AAPL   |Apple Inc.            |Information Technology
  </code></pre>
  
  <p>Right now I am running a SQL statement like this in a loop. Each iteration I change which industry to look at.</p>
  
  <pre><code>SELECT ticker FROM company WHERE industry = 'Information Technology'
  </code></pre>
  
  <p>But that means I have to make a call to the database for each industry just to get the tickers related to it. What I want is to make one database call that returns multiple results. So the first result would be a list of all the tickers for the first industry, the second result would be all the tickers for the second industry etc.</p>
  
  <p>I tried this SQL, but it just gave me one ticker for each industry, not a full list</p>
  
  <pre><code>SELECT ticker, industry FROM company GROUP BY industry
  </code></pre>