SQL query help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
anthony88guy
Forum Contributor
Posts: 246
Joined: Thu Jan 20, 2005 8:22 pm

SQL query help

Post by anthony88guy »

Each time you login a table is populated with the following: userid, time, ip, sid. Now I want to show the last time the person logged in. So my query will search my table for that person’s userid with LIMIT 2, now how to I grab the second row found? I looked on php.net and didn’t see any mysql functions that fit my criteria.

I’m also trying to rank the user. I query'd the table and searched credits DESC, now how do I find the users row thus showing his/her rank?

Thanks.
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Code: Select all

select * from my_table where user_id = 2 order by fld_time desc limit 1,1
Post Reply