SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member
    Join Date
    Nov 2003
    Location
    Watervliet, mi
    Posts
    651
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Removing where count =1?

    $link = $DB_site->query("select ref
    , count(*) as refcount
    from amartinref
    group by ref
    ORDER BY refcount DESC");

    Basically my ref log has gotten large enough that I can't run it within the allocated amount of time anymore. How would I do a query to eliminate any URL's that are in the table say less than 3 times?

  2. #2
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Is your table indexed? if not you will be able to speed up your queries significantly.

    To delete with less than three then do something like:
    Code:
    delete from amartinref where ref IN (
    select ref
    from amartinref
    group by ref
    having count(ref) < 3
    )


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
  •