Note that there are some explanatory texts on larger screens.

plurals
  1. POSelect first product from first category, then first product from second category and so on
    text
    copied!<p>I need a select query that would fetch the first video from category id 1 and then the first video for category two, then first video for category three and so on for the remaining categories</p> <p>and then second video for category 1, then second video from category 2 and so on.</p> <p>This is my database table structure:</p> <pre><code>CREATE TABLE videos( video_id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, video_filename CHAR(255), video_title CHAR(255), description CHAR(255), video_category INT UNSIGNED, video_levels INT UNSIGNED, video_type INT UNSIGNED, status INT UNSIGNED ); INSERT INTO videos VALUES (1, 'L_1_F_1.mp4', 'Michael Jordan', 'Michael Jordan Footwork', 4, 1, 0, 1), (4, 'L_2_B_1.mp4', 'ball', 'handling', 3, 1, 0, 1), (3, 'L_1_C_2.mp4', 'Core Training', 'Core Training', 1, 1, 0, 1), (5, 'L_1_S_1.mp4', 'Jukes', 'test jukes', 2, 1, 0, 1) ; </code></pre> <p>And the table:</p> <pre><code>| VIDEO_ID | VIDEO_FILENAME | VIDEO_TITLE | DESCRIPTION | VIDEO_CATEGORY | VIDEO_LEVELS | VIDEO_TYPE | STATUS | ------------------------------------------------------------------------------------------------------------------------------ | 1 | L_1_F_1.mp4 | Michael Jordan | Michael Jordan Footwork | 4 | 1 | 0 | 1 | | 3 | L_1_C_2.mp4 | Core Training | Core Training | 1 | 1 | 0 | 1 | | 4 | L_2_B_1.mp4 | ball | handling | 3 | 1 | 0 | 1 | | 5 | L_1_S_1.mp4 | Jukes | test jukes | 2 | 1 | 0 | 1 | </code></pre> <p>See it on <a href="http://sqlfiddle.com/#!2/2065a/1" rel="nofollow">SQL Fiddle</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload