FAQ |
Kalender |
![]() |
#1 | ||
|
|||
Medlem
|
Hej!
Nu vill jag sätta in slashdot kommentarerna i mitt galleri program. Table ser ut såhär: Kod:
id | subject | date | in_reply_to | +----+------------------+---------------------+-------------+ | 1 | Original | 0000-00-00 00:00:00 | NULL | 2 | Another original | 0000-00-00 00:00:01 | NULL | 3 | Reply to 1 | 0000-00-00 00:00:02 | 1 | 4 | Reply to 1-2 | 0000-00-00 00:00:05 | 1 Kod:
select id,subject,date,in_reply_to from blog_comments WHERE blog_id = 1 ORDER BY in_reply_to, date; Kod:
id | subject | date | in_reply_to | +----+------------------+---------------------+-------------+ | 1 | Original | 0000-00-00 00:00:00 | NULL | 3 | Reply to 1 | 0000-00-00 00:00:02 | 1 | 4 | Reply to 1-2 | 0000-00-00 00:00:05 | 1 | 2 | Another original | 0000-00-00 00:00:01 | NULL Går detta ? Tack på förhand |
||
![]() |
![]() |
![]() |
#2 | ||
|
|||
Mycket flitig postare
|
Kod:
select id,subject,date,isnull(in_reply_to,id) AS irt from blog_comments WHERE blog_id = 1 ORDER BY irt, date; |
||
![]() |
![]() |
![]() |
#3 | ||
|
|||
Medlem
|
great! det funkar utmärkt!
Nu ska jag bara klura ut hur jag ska få "original post" att sorteras efter datum. Tack än en eg0master ![]() |
||
![]() |
![]() |
![]() |
#4 | ||
|
|||
Mycket flitig postare
|
Kod:
select c.id AS id,c.subject AS subject,c.date AS date,isnull(c.in_reply_to,id) AS irt, od.date AS org_date from blogcomments c, blogcomments od where isnull(c.in_reply_to, c.id) = od.id and c.blog_id = 1 ORDER BY od.date, c.date |
||
![]() |
![]() |
Svara |
|
|