Başka bir tablodaki mesaj ile sipariş

0 Cevap php

I have created a feature where users can start new topics (similar to forums). At the moment on a page, the query for the topics are as follows:

$q = "SELECT ".TBL_COMMUNITYTHREADS.".title, ".TBL_COMMUNITYTHREADS.".id, 
    ".TBL_COMMUNITYTHREADS.".date, ".TBL_COMMUNITYTHREADS.".author, ".TBL_USERS.".username FROM ".TBL_COMMUNITYTHREADS." 
        INNER JOIN ".TBL_USERS." ON ".TBL_COMMUNITYTHREADS.".author = ".TBL_USERS.".id
        WHERE type = '$type'
        ORDER BY date DESC LIMIT $offset, $rowsperpage ";

Tablolar sabitler ve ofset ve bir sayfada kaç mesaj sınırlamak için geçirilen değişkenler RowsPerPage vardır.

At the moment though, all the topics are ordered by the date. I want them to be ordered by the latest response. Similarly to forums, when the reponse inside the topic is newest, that topic will go to the top.

Konular tbl_communityreplies yılında tbl_communitythreads ve cevaplarda saklanır.

Nasıl son repsonse bunları emretti yapabilirsiniz.

Onlar tbl_communityreplies yılında ThreadId ile bağlantılıdır. Ayrıca bu birinde tarih sütundur.

Bu nasıl okunması için teşekkür ederim, ben sadece cant düşünüyorum.

0 Cevap