Jump to content

MySQL Query WHERE, ORDER BY and start from + amount

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
SELECT * FROM forum_threads WHERE SectionID = $section ORDER BY date DESC $start,20
That query returns an error.
It worked like this:
SELECT * FROM forum_threads WHERE SectionID = $section

What its mean't to do:
1. Get threads.
2. Only get the ones for this section
3. Order them bye the date.
4. Start from $start and only get 20 results.
Note: $start = page number multiplied by 20.

I have this working but with out the WHERE statement.

Thanks in advanced G2G
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
"SELECT * 

FROM `forum_threads`

WHERE  SectionID = $section 

ORDER BY `date` DESC 

LIMIT $start, 20"

Edited by John, 28 October 2010 - 10:00 PM.

Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
Thanks NullW0rm
Seems i missed the LIMIT part, I still got an error but fixed by removing the ' parts- mayby the wrong key (oh i see its this one ').
Hey what happened to your worm???
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).