ORDER BY rand() LIMIT 20 SELECT * FROM `questions` WHERE category IN (90,91,92,93,94,95) ORDER BY `category` ASC SELECT * FROM ( SELECT * FROM users ORDER BY rand() LIMIT 20 ) T1 ORDER BY name SELECT * FROM `questions` WHERE category IN(90, 91, 92, 93, 94, 95) ORDER BY RAND() LIMIT 20 DROP TABLE test_table; CREATE TABLE test_table SELECT `id`, `text`, `correct` FROM questions WHERE id < 12 INSERT INTO test_table SELECT `id`, `text`, `correct` FROM questions WHERE id = 12 INSERT INTO tfq( `cat_0`, `question`, `correct`, `incorrect_0`, `incorrect_1`, `incorrect_2`, `explanation`, `language`, `source`, `source_id`, `asked`, `answered` ) SELECT 91, `text`, `correct`, `incorrect0`, `incorrect1`, `incorrect2`, `explanation`, "SE", "PPL-A", `id`, 0, 0 FROM `questions` WHERE `category` IN(90, 91, 92, 93, 94, 95) ORDER BY `id` INSERT INTO tulebose_flight_quiz_s.tfq( `cat_0`, `question`, `correct`, `incorrect_0`, `incorrect_1`, `incorrect_2`, `explanation`, `language`, `source`, `source_id`, `asked`, `answered` ) SELECT 0, `text`, `correct`, `incorrect0`, `incorrect1`, `incorrect2`, `explanation`, "EN", "PPL-A", `id`, 0, 0 FROM tulebose_flight_quiz_e.questions WHERE `attachments` = "" ORDER BY `id` DROP TABLE test_table; CREATE TABLE test_table SELECT `id`, `text`, `correct` FROM questions WHERE id < 12 INSERT INTO test_table SELECT `id`, `text`, `correct` FROM questions WHERE id = 12 SELECT `id`, `question`, `correct`, `incorrect_0`, `incorrect_1`, `incorrect_2`, `explanation` FROM tfq WHERE `language` = "SE" AND `answered` = 0 ORDER BY RAND() LIMIT 1 SELECT `id`, `question`, `correct`, `incorrect_0`, `incorrect_1`, `incorrect_2`, `explanation` FROM tfq WHERE `language` = "EN" AND `answered` = 0 AND `id` > 232 ORDER BY RAND() LIMIT 100 UPDATE `tfq` SET `answered` = '0' WHERE `tfq`.`id` = 233; INSERT INTO tfq( `cat_0`, `question`, `correct`, `incorrect_0`, `incorrect_1`, `incorrect_2`, `explanation`, `language`, `source`, `source_id`, `asked`, `answered` ) SELECT 91, `text`, `correct`, `incorrect0`, `incorrect1`, `incorrect2`, `explanation`, "SE", "PPL-A", `id`, 0, 0 FROM `questions` WHERE `category` IN(90, 91, 92, 93, 94, 95) ORDER BY `id` INSERT INTO tulebose_flight_quiz_s.tfq( `cat_0`, `question`, `correct`, `incorrect_0`, `incorrect_1`, `incorrect_2`, `explanation`, `language`, `source`, `source_id`, `asked`, `answered` ) SELECT 91, `text`, `correct`, `incorrect0`, `incorrect1`, `incorrect2`, `explanation`, "EN", "PPL-A", `id`, 0, 0 FROM tulebose_flight_quiz_e.questions WHERE `category` IN(554, 592, 593, 594, 595, 596, 597) ORDER BY `id`