Jump to content


Concatenating Integers with MySQL, or "get last 10 entr

  • Please log in to reply
2 replies to this topic

#1 Genesis

  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 November 2003 - 11:26 AM

Hi there,

For my website I have a news system that will have thousands of entries. What I would like to do is retrieve the 10 most recent entries.

Is there a \"get X most recent entries based on index\" function? I do NOT know how to use indexes, or autoincrements or anything like that. I have tried and tried to understand them, but no tutorial I\'ve seen yet has explained them in such a way that I can understand.

Or, back to my first question: is there a way to concatenate two integers? I do NOT want them added.. just appending one onto the other, like a string. (I know about the concat() function, but I dunno if it works with integers..)

The reason I need to do this is because if I cannot figure out indexes, I will have to concatenate the date with the time and use that as one big number to determine which 10 posts were made most recently.

Any help is greatly appreciated :)

#2 Derek

  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationTennessee

Posted 05 November 2003 - 02:37 PM

Just add an id field to your news table, and give it an id field (make it the primary key, and make it AUTO_INCREMENT).
then use this in your query:

LIMIT 0,10 ORDER BY some_id_field DESC
function comment(s)


	if (i_know_what_to_do_shut_up_i_dont_need_your_help_mode) {
   return  	} else {    return s  	}  }
ext/skeleton/create_stubs, lines 40-47. - PHP Core

#3 Genesis

  • Members
  • Pip
  • Newbie
  • 7 posts

Posted 05 November 2003 - 07:25 PM

LOL.. all this struggling and it\'s that easy!

Thanks a bunch!! :)

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users