Re: Workings of a forum
Date: 28 Nov 2018 03:31:41 GMT
Message-ID: <works-20181128042328_at_ram.dialup.fu-berlin.de>
ram_at_zedat.fu-berlin.de (Stefan Ram) writes:
>groovee_at_cyberdude.com writes:
>>What I want is, on the main page of the site, to display the thread titles =
>>WITH THE THREAD WITH THE LATEST POST FIRST (just as is done in so many plac=
>Main.sql
The following also works here with MySQL and InnoDB.
But I am not sure whether this is guaranteed by ISO SQL or MySQL or is just unspecified behavior.
Main.sql
\W SET sql_mode = 'ANSI,TRADITIONAL';
DROP SCHEMA S; CREATE SCHEMA S; USE S;
CREATE TABLE POST( POST INT, THREAD INT, TIME INT );
INSERT INTO POST( POST, THREAD, TIME )VALUES( 10, 100, 20 ); INSERT INTO POST( POST, THREAD, TIME )VALUES( 12, 100, 30 ); INSERT INTO POST( POST, THREAD, TIME )VALUES( 11, 100, 10 ); INSERT INTO POST( POST, THREAD, TIME )VALUES( 14, 101, 50 ); INSERT INTO POST( POST, THREAD, TIME )VALUES( 13, 101, 60 ); INSERT INTO POST( POST, THREAD, TIME )VALUES( 16, 101, 60 ); INSERT INTO POST( POST, THREAD, TIME )VALUES( 15, 101, 40 );SELECT THREAD, POST, TIME
FROM( SELECT * FROM POST ORDER BY TIME DESC )S GROUP BY THREAD ORDER BY TIME DESC; transcript
+--------+------+------+
| THREAD | POST | TIME |
+--------+------+------+
| 101 | 13 | 60 |
| 100 | 12 | 30 |
+--------+------+------+
Received on Wed Nov 28 2018 - 04:31:41 CET