Jump to content


Photo

MySQL question.


  • Please log in to reply
5 replies to this topic

#1 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 02 August 2006 - 06:34 PM

If I have a comment system for each so and so piece of content on my site, and the comments are in a seperate table. If the comment table is set up like :


Comment Table:

pagenumber      user          comment                              commentnumber
34                john          Hey, I like to post comments!    305 (auto increment)


and to get the comments for the page:

select * where pagenumber = '$pagenumber'

Would this be the best method for getting the comments if I expect the comments to get into the hundred-thousands?

I really can't think of any other way.



#2 tensionx

tensionx
  • New Members
  • Pip
  • Newbie
  • 7 posts

Posted 02 August 2006 - 06:38 PM

How many comments do you want to see per user? Do you want to see the last ten?
SELECT top 10,* from (table)
WHERE blah blah

What exactly do you want to see?

#3 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 02 August 2006 - 06:40 PM

comments are going to be paginated on each page, but I'm asking if that's the method people use? The most efficient way?


#4 bpops

bpops
  • Members
  • PipPipPip
  • Advanced Member
  • 232 posts

Posted 02 August 2006 - 06:43 PM

That is the method I use on one of my sites, http://www.scriptcrawler.net.  If you were looking at all the scripts starting with "a" for example, I select them all, then cycle through them picking out the appropriate ones for each page. I compute the first and last item to pull for each page then display it.

My way is a tad complicated though, and I'm not sure if there's a better way.

#5 dagnasty

dagnasty
  • Members
  • PipPipPip
  • Advanced Member
  • 66 posts

Posted 02 August 2006 - 07:17 PM

Alright cool, thanks a lot.

Why don't you set the first letter of the script title as "startswith" in the database at the posting of the script into database, then do

select * where startswith = '$letter' SORT BY title

#6 ryanlwh

ryanlwh
  • Staff Alumni
  • Advanced Member
  • 511 posts

Posted 02 August 2006 - 07:26 PM

use LIMIT
SELECT * FROM table LIMIT 0,10
Show 10 records, starting from row 0.
Please use EDIT * 100...
Please use
or [php] * 1000...

PLEASE READ THE POSTED SOLUTIONS CAREFULLY * 1000000...




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users