Page 1 of 1

how 2 do this?(mysql)

Posted: Sat Sep 14, 2002 3:34 pm
by qads
hi,
i am makeing a forum and i have ranking table

here is ranking table layout:
ID:1
title: user
required_posts = 0

ID: 2
title: coder
required_posts: 15
____________________
here is users table:
ID: 1
Username: user1
posts: 4
______________________
so, user1 has a rank title of user by looking at this but how do i do this in a query? how do i get the correct rank title based on number of posts?

i can't seem to understand that :x

thanks alot for your time

Posted: Sat Sep 14, 2002 6:18 pm
by hob_goblin
something like

SELECT * FROM ranks WHERE required_posts < '$numofposts'

then just grab the first row or the last row, i am not sure

Posted: Sun Sep 15, 2002 3:00 am
by Takuma
I think you should be better using

Code: Select all

SELECT * FROM ranks WHERE required_posts <= '$numofposts'

Posted: Sun Sep 15, 2002 7:36 am
by qads
nope, what i have done is this:

Code: Select all

select * from ranks where required_posts < $noofposts order by ID DESC limit 1
this gets only one record and cos it is in desc order it gets the correct one :P