Login | Register | FAQ
Anonymous

mysql query for comment

+ Post a reply

10 posts Page 1 of 1


mysql query for comment

by shadmank » Mon Dec 02, 2013 7:51 pm

i want to retrieve comments of a post from database in descending order with limit 3 but want to show them upside down in ascending order
User avatar

shadmank

  • Posts: 21
  • Joined: Mon Dec 02, 2013 7:45 pm

Re: mysql query for comment

by shadmank » Mon Dec 02, 2013 7:53 pm

can please somebody help me
User avatar

shadmank

  • Posts: 21
  • Joined: Mon Dec 02, 2013 7:45 pm

Re: mysql query for comment

by XainPro » Tue Dec 03, 2013 3:48 pm

Code: Select all
select * from meta_comments order by id desc limit 3


i do not know your table name replace meta_comments from your table name
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: mysql query for comment

by shadmank » Tue Dec 03, 2013 6:07 pm

yeah but i want that 3 last comments in ascending order
i want last 3 results in ascending order
User avatar

shadmank

  • Posts: 21
  • Joined: Mon Dec 02, 2013 7:45 pm

Re: mysql query for comment

by XainPro » Tue Dec 03, 2013 6:39 pm

THEN DO THIS

Code: Select all
select * from meta_comments order by id ASC limit 3
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: mysql query for comment

by shadmank » Wed Dec 04, 2013 3:39 am

i know that but i
want last 3 comments in ascending order and not first three
User avatar

shadmank

  • Posts: 21
  • Joined: Mon Dec 02, 2013 7:45 pm

Re: mysql query for comment

by XainPro » Fri Dec 06, 2013 1:11 pm

Ok try this

Code: Select all
SELECT *
   FROM (SELECT *
      FROM `comments` ORDER BY id DESC LIMIT 0 , 3) t
ORDER BY id ASC;
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: mysql query for comment

by shadmank » Mon Dec 16, 2013 6:54 am

its not working
here is my query string
$string="SELECT * FROM ( SELECT * FROM post_comments,people WHERE post_comments.statusid=$statusid && post_comments.userid=people.userid ORDER BY post_comments.date DESC ) ORDER BY post_comments.date ASC ";
User avatar

shadmank

  • Posts: 21
  • Joined: Mon Dec 02, 2013 7:45 pm

Re: mysql query for comment

by XainPro » Thu Dec 19, 2013 2:13 pm

break your query in two part and check both are working
1: check is this query returning any results
Code: Select all
SELECT * FROM post_comments,people WHERE post_comments.statusid=$statusid && post_comments.userid=people.userid ORDER BY post_comments.date DESC


then try to run this query and tell me does this query give any error or return some results ?

$string="SELECT * FROM ( SELECT * FROM post_comments, people WHERE post_comments.statusid=$statusid && post_comments.userid=people.userid ORDER BY post_comments.date DESC ) t ORDER BY t.post_comments.date ASC ";
User avatar

XainPro

  • Posts: 3933
  • Joined: Fri Feb 17, 2012 8:10 pm

Re: mysql query for comment

by shadmank » Tue Dec 31, 2013 12:57 pm

nopes its not working
User avatar

shadmank

  • Posts: 21
  • Joined: Mon Dec 02, 2013 7:45 pm


+ Post a reply

Page 1 of 1