title: Is it possible to get the list of rows grouped together by a column name in Mysql?
body: <p>In my database, I have a table called 'results' with four columns (name,device,passed,failed). Suppose if there are 4 rows in the table as below.</p>
  <pre><code>name   device   passed failed
  
  test1  device_1    2      1
  test1  device_2    3      0
  test2  device_1    1      2
  test2  device_2    2      1
  </code></pre>
  <p>I want the below result:</p>
  <pre><code>[(test1,device_1,2,1),(test1,device_2,3,0)]
  [(test2,device_1,1,2),(test1,device_2,2,1)]
  </code></pre>
  <p>Is it possible to get that result with only one query to DB?</p>
  <p>currently I am querying database twice, first getting a list of distinct names and then getting rows with that name. Below is the pseudo code.</p>
  <pre><code> test_names = SELECT DISTINCT name FROM results
   for test_name in test_names: 
        rows = SELECT * FROM results WHERE name=test_name
  </code></pre>
  <p>then I am processing rows to get the object structure that I wanted.</p>