title: SQL: Issue retrieving data via Select query in a specific (static) order
body: <p>I am currently trying to create a MySQL query, which outputs data from a specific table (images) using a static order. I am currently using UNION ALL to do this, but I'm kinda stuck now.</p>
  
  <p>Here is what I want it to do:</p>
  
  <p>I have a  table named <em>images</em> with the following fields: user_id, image,  image_dimension (this field values: small, wide, tall, large).</p>
  
  <p>From the images table, I want to retrieve images with specific dimensions in a static order, to fit these into my static image grid. Now it gets complicated: I only want one (1) image per user_id.</p>
  
  <p>This is my try so far:</p>
  
  <pre><code>SELECT
      *
  FROM
  (
  
      (SELECT * FROM `artworks` WHERE img = 'Large' LIMIT 1)
      UNION ALL
      (SELECT * FROM `artworks` WHERE img = 'Small' LIMIT 2)
      UNION ALL
      (SELECT * FROM `artworks` WHERE img = 'Large' LIMIT 1)
      UNION ALL
      (SELECT * FROM `artworks` WHERE img = 'Wide' LIMIT 1)
      UNION ALL
      (SELECT * FROM `artworks` WHERE img = 'Small' LIMIT 2)
      UNION ALL
      (SELECT * FROM `artworks` WHERE img = 'Tall' LIMIT 2)
      UNION ALL
      (SELECT * FROM `artworks` WHERE img = 'Large' LIMIT 1)
  ) AS order
  </code></pre>
  
  <p>This query pulls images with a specific dimension from the table "images" and with LIMIT - I get the amount I need for the order. This works so far, but it doesn't allow me to only get one image per user_id while keeping the order.</p>
  
  <p>How can I make sure I get the order (see query) but only get one image per user_id?</p>
  
  <p>Order again is: 1x Large, 2x Small, 1x Large, 1x wide, 2x small, 2x tall and 1x large)</p>
  
  <p>Sorry for my bad english, let me know if you need any further description.</p>
  
  <p><strong>Edit:</strong></p>
  
  <pre><code>Table format artworks:
  id | user_id | img_name | img
  
  Sample data from artworks:
  1  | 1       | Test 1   | Large
  2  | 1       | Test 2   | Large
  3  | 2       | Test 3   | Small
  4  | 2       | Test 4   | Small
  5  | 2       | Test 5   | Small
  6  | 3       | Test 6   | Small
  7  | 3       | Test 7   | Small
  8  | 3       | Test 8   | Small
  9  | 4       | Test 9   | Large
  10 | 4       | Test 10  | Large
  11 | 5       | Test 11  | Small
  12 | 5       | Test 12  | Wide
  13 | 6       | Test 13  | Small
  14 | 7       | Test 14  | Small
  
  My expected result (ORDER BY id DESC) to get latest img of each user:
  
  2  | 1       | Test 2   | Large
  5  | 2       | Test 5   | Small
  8  | 3       | Test 8   | Small
  10 | 4       | Test 10  | Large
  12 | 5       | Test 12  | Wide
  13 | 6       | Test 13  | Small
  14 | 7       | Test 14  | Small
  </code></pre>