clear markdown compare help donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 497215 fiddles created (9443 in the last week).

create table comments(id int not null, answer_id int not null, content varchar(100), dt datetime);
 hidden batch(es)


INSERT INTO comments VALUES (1,1,'decoder','2016-09-24 13:40:44'),(2,1,'underflowing','2016-09-26 11:07:57'),(3,1,'suspensions','2016-09-25 07:06:34'),(4,1,'stick','2016-09-26 04:21:18'),(5,1,'emitted','2016-09-21 11:50:13'),(6,1,'Quasimodo','2016-09-21 08:05:46'),(7,1,'Kabuki','2016-09-23 23:03:53'),(8,1,'compost','2016-09-27 17:59:47'),(9,1,'baseband','2016-09-26 23:39:13'),(10,1,'numismatist','2016-09-26 17:21:37'),(11,1,'Booleans','2016-09-22 20:17:37'),(12,1,'sacrifice','2016-09-22 22:42:09'),(13,1,'tempter','2016-09-25 02:34:15'),(14,1,'leveler','2016-09-22 00:35:48'),(15,1,'dissent','2016-09-25 03:55:34'),(16,1,'ergodic','2016-09-26 20:32:13'),(17,1,'curtained','2016-09-23 05:36:48'),(18,1,'imprisonment','2016-09-23 11:38:46'),(19,1,'Macaulayisms','2016-09-24 09:27:25'),(20,1,'horrible','2016-09-23 13:23:26');
 hidden batch(es)


INSERT INTO comments VALUES (1,5,'decoder','2016-09-24 13:40:44'),(2,5,'underflowing','2016-09-26 11:07:57'),(3,5,'suspensions','2016-09-25 07:06:34'),(4,5,'stick','2016-09-26 04:21:18'),(5,5,'emitted','2016-09-21 11:50:13'),(6,5,'Quasimodo','2016-09-21 08:05:46'),(7,5,'Kabuki','2016-09-23 23:03:53'),(8,5,'compost','2016-09-27 17:59:47'),(9,5,'baseband','2016-09-26 23:39:13'),(10,5,'numismatist','2016-09-26 17:21:37'),(11,5,'Booleans','2016-09-22 20:17:37'),(12,5,'sacrifice','2016-09-22 22:42:09'),(13,5,'tempter','2016-09-25 02:34:15'),(14,5,'leveler','2016-09-22 00:35:48'),(15,5,'dissent','2016-09-25 03:55:34'),(16,5,'ergodic','2016-09-26 20:32:13'),(17,5,'curtained','2016-09-23 05:36:48'),(18,5,'imprisonment','2016-09-23 11:38:46'),(19,5,'Macaulayisms','2016-09-24 09:27:25'),(20,5,'horrible','2016-09-23 13:23:26');
 hidden batch(es)


select * from comments;
id answer_id content dt
1 1 decoder 2016-09-24 13:40:44
2 1 underflowing 2016-09-26 11:07:57
3 1 suspensions 2016-09-25 07:06:34
4 1 stick 2016-09-26 04:21:18
5 1 emitted 2016-09-21 11:50:13
6 1 Quasimodo 2016-09-21 08:05:46
7 1 Kabuki 2016-09-23 23:03:53
8 1 compost 2016-09-27 17:59:47
9 1 baseband 2016-09-26 23:39:13
10 1 numismatist 2016-09-26 17:21:37
11 1 Booleans 2016-09-22 20:17:37
12 1 sacrifice 2016-09-22 22:42:09
13 1 tempter 2016-09-25 02:34:15
14 1 leveler 2016-09-22 00:35:48
15 1 dissent 2016-09-25 03:55:34
16 1 ergodic 2016-09-26 20:32:13
17 1 curtained 2016-09-23 05:36:48
18 1 imprisonment 2016-09-23 11:38:46
19 1 Macaulayisms 2016-09-24 09:27:25
20 1 horrible 2016-09-23 13:23:26
1 5 decoder 2016-09-24 13:40:44
2 5 underflowing 2016-09-26 11:07:57
3 5 suspensions 2016-09-25 07:06:34
4 5 stick 2016-09-26 04:21:18
5 5 emitted 2016-09-21 11:50:13
6 5 Quasimodo 2016-09-21 08:05:46
7 5 Kabuki 2016-09-23 23:03:53
8 5 compost 2016-09-27 17:59:47
9 5 baseband 2016-09-26 23:39:13
10 5 numismatist 2016-09-26 17:21:37
11 5 Booleans 2016-09-22 20:17:37
12 5 sacrifice 2016-09-22 22:42:09
13 5 tempter 2016-09-25 02:34:15
14 5 leveler 2016-09-22 00:35:48
15 5 dissent 2016-09-25 03:55:34
16 5 ergodic 2016-09-26 20:32:13
17 5 curtained 2016-09-23 05:36:48
18 5 imprisonment 2016-09-23 11:38:46
19 5 Macaulayisms 2016-09-24 09:27:25
20 5 horrible 2016-09-23 13:23:26
 hidden batch(es)


select id, answer_id, content from comments where answer_id =1 limit 10;
id answer_id content
1 1 decoder
2 1 underflowing
3 1 suspensions
4 1 stick
5 1 emitted
6 1 Quasimodo
7 1 Kabuki
8 1 compost
9 1 baseband
10 1 numismatist
 hidden batch(es)


SELECT id, answer_id, content, dt FROM ( SELECT id, answer_id, content, dt, @rn := IF(@prev = answer_id, @rn + 1, 1) AS rn, @prev := answer_id FROM comments JOIN (SELECT @prev := NULL, @rn := 0) AS vars ORDER BY answer_id, dt DESC) AS T1 WHERE rn <= 10;
id answer_id content dt
8 1 compost 2016-09-27 17:59:47
9 1 baseband 2016-09-26 23:39:13
16 1 ergodic 2016-09-26 20:32:13
10 1 numismatist 2016-09-26 17:21:37
2 1 underflowing 2016-09-26 11:07:57
4 1 stick 2016-09-26 04:21:18
3 1 suspensions 2016-09-25 07:06:34
15 1 dissent 2016-09-25 03:55:34
13 1 tempter 2016-09-25 02:34:15
1 1 decoder 2016-09-24 13:40:44
8 5 compost 2016-09-27 17:59:47
9 5 baseband 2016-09-26 23:39:13
16 5 ergodic 2016-09-26 20:32:13
10 5 numismatist 2016-09-26 17:21:37
2 5 underflowing 2016-09-26 11:07:57
4 5 stick 2016-09-26 04:21:18
3 5 suspensions 2016-09-25 07:06:34
15 5 dissent 2016-09-25 03:55:34
13 5 tempter 2016-09-25 02:34:15
1 5 decoder 2016-09-24 13:40:44
 hidden batch(es)