SQL only the first row of each value MYSQL version 5.7.31
How do I make it show the distinct rows of the value/column mainthreadid with the highest value of date?
Note that the data is filtered using
WHERE approved = 1 AND section != 150 

A fiddle is available here.
Fiddle DDL and DML
Table
CREATE TABLE forum (
    id int,
    mainthreadid int,
    section int,
    approved int,
    date int(20),
    title varchar(255),
    text varchar(255)
   
);

Sample Data
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (1, 1, 5, 1, 1000, &quot;title1&quot;, &quot;text1&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (2, 2, 5, 1, 1000, &quot;title2&quot;, &quot;text2&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (3, 2, 5, 1, 1001, &quot;title3&quot;, &quot;text3&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (4, 2, 5, 1, 1002, &quot;title4&quot;, &quot;text4&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (5, 2, 5, 1, 1003, &quot;title5&quot;, &quot;text5&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (6, 2, 5, 1, 1004, &quot;title6&quot;, &quot;text6&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (7, 2, 5, 0, 1005, &quot;title7&quot;, &quot;text7&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (8, 8, 150, 1, 1004, &quot;title8&quot;, &quot;text8&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (9, 1, 5, 1, 1006, &quot;title9&quot;, &quot;text9&quot;);
INSERT INTO forum (id, mainthreadid, section, approved, date, title, text)
VALUES (10, 1, 5, 1, 1005, &quot;title10&quot;, &quot;text10&quot;);

SQL Statement
SELECT date, id, mainthreadid 
FROM `forum` 
WHERE approved = 1 AND section != 150 ORDER BY date DESC

Resultset
My desired result set would be:
date    id  mainthreadid
1006    9   1
1004    6   2
Maybe you need in
SELECT forum.*
FROM forum
JOIN ( SELECT mainthreadid, MAX(`date`) `date`
       FROM forum
       GROUP BY mainthreadid ) lastdates USING (mainthreadid, `date`)

?
fiddle
For each mainthreadid only last row (the row with greatest date) is selected. If there exists more than one such row (the same maximal date) then all of them will be returned.


you dont include checks for approved = 1 and if section != 150

No problems.
SELECT forum.*
FROM forum
JOIN ( SELECT mainthreadid, MAX(`date`) `date`
       FROM forum
       WHERE approved = 1 AND section != 150
       GROUP BY mainthreadid ) lastdates USING (mainthreadid, `date`)

fiddle