SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: MySQL query..

  1. #1
    exit();
    Join Date
    Jul 2000
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL query..

    Code:
    $activequery = mysql_query("SELECT DISTINCT user, time FROM tracking WHERE (time > $expirytime)");
    The above works..except for one thing. It will return every single username out of that table..

    It's in it like this currently:

    count time user ip currentpage
    32 996132666 mkaufman unknown index
    30 996132649 mkaufman unknown index
    36 996166966 test unknown index
    29 996132642 mkaufman unknown index
    35 996166714 test unknown index

    It is returning all of them, because the 'count field' is different and the 'time' field is different. The 'currentpage' field could be different depending on what page the user is on.

    So my question is, how can I tell it to DISTINCTly get only 1 user from the database..and maybe the latest user? So like instaed of getting user mkaufman(count 30) it would get user mkaufman(count32)?

    Thanks

  2. #2
    Serial Publisher silver trophy aspen's Avatar
    Join Date
    Aug 1999
    Location
    East Lansing, MI USA
    Posts
    12,937
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LIMIT 1
    Chris Beasley - I publish content and ecommerce sites.
    Featured Article: Free Comprehensive SEO Guide
    My Guide to Building a Successful Website
    My Blog|My Webmaster Forums

  3. #3
    exit();
    Join Date
    Jul 2000
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Uh, wouldn't that just return 1 result total? What if 2,3,4 or 5 other users were on?

  4. #4
    exit();
    Join Date
    Jul 2000
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, sorry..by 1 user I meant only 1 of the same user..

    Now it displays them like this:

    test, test, test, mkaufman, test

    I want it like:

    test, mkaufman



  5. #5
    exit();
    Join Date
    Jul 2000
    Posts
    759
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, got it resolved

    I just didn't select the 'time' field..I thought I need it but it turns out I don't.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •