Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8721163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:10:34+00:00 2026-06-13T07:10:34+00:00

I’ve the following table. comment postid userid tempid c1 199 100003052455644 89 c2 193

  • 0

I’ve the following table.

comment    postid    userid            tempid

c1         199       100003052455644    89
c2         193       100003052455644    2
c4         199       100003052455644    82
c5         198       100003052455644    5
c6         199       1097517748         65

Now I wanted to retrieve data in such a way that the data is first ordered in descending according to postid column then it is ordered in the order in which rows are inserted.Now when I retrieve the values in which postid is ordered by descending it gives me the result like this.

comment    postid    userid            tempid

c6         199       1097517748         65
c4         199       100003052455644    69
c1         199       100003052455644    82
c5         198       100003052455644    5
c2         193       100003052455644    2

As you can see the userid who commented the last is appearing at first position.In the 199 postid.I came accross this problem by sorting the tempid column in the descending order also.But is there a way that i do not use the tempid column because this table will be filled very quickly and the auto-increment column will fill in quickly so I will be removing this tempid column in the future.So I thought it was not a good idea to do it like this is there any other solution for this ?

Right Now I am using the following query which is giving me the correct result.

 SELECT comments.comment,comments.postid,user.name,comments.userid,comments.tempid 
 FROM
  user
   INNER JOIN comments ON user.userid=comments.userid
   INNER JOIN posts ON posts.postID = comments.postid
 WHERE 
 comments.postid <=  
 (SELECT MAX(postid) FROM
   (
     SELECT wall.postid FROM wall,posts WHERE  
     wall.postid = posts.postid AND posts.userid=?
     ORDER BY wall.postid DESC LIMIT 10 OFFSET ?
   )sq1
 )

 AND
 comments.postid >= 
 (SELECT MIN(postid) FROM
  (
    SELECT wall.postid FROM wall,posts WHERE
    wall.postid = posts.postid AND posts.userid=?
    ORDER BY wall.postid DESC LIMIT 10 OFFSET ?
  )sq2
 ) 

 AND
 posts.userid = ? 
 ORDER BY comments.postid DESC,comments.tempid DESC;

Only the last line is of our concern.I want to achive the same result while removing the comments.tempid DESC clause . is it possible?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:10:34+00:00Added an answer on June 13, 2026 at 7:10 am

    I want to achive the same result while removing the comments.tempid DESC clause . is it possible?

    Yes. You could add another column with a timestamp instead of an integer. But it’s possible that two rows will have the same timestamp, so it’s not a perfect solution.

    But is there a way that i do not use the tempid column because this table will be filled very quickly and the auto-increment column will fill in quickly so I will be removing this tempid column in the future.So I thought it was not a good idea to do it like this is there any other solution for this ?

    The autoincrement column can be of type bigint. This will be enough for you.

    Related

    • What if I need a very very big autoincrement ID?
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.