There are 2 tables, one for topics, the second for answers.
How to use 1 SQL query to display 5 extreme topics, with only 1 extreme answer.
In this case, new answers should raise the topic higher in the list, as it works with the use of DESC
.
我试图这样做,但是,它做得很正确:
SELECT `t2`.`date` AS `date`,`t1`.`name` AS `name`
FROM `quests`
AS `t1`
LEFT JOIN `answers`
AS `t2`
ON `t2`.`quest_id` = `t1`.`id`
GROUP BY `t1`.`id` DESC
How to do this correctly?
UPD:
It should look like this:
Quest1
- Answer 1,
- Answer 2
Qest2
- Answer 1,
- Answer 2,
- Answer 3
因此,它希望:
Quest2
- Answer3
Quest1
- Answer2