SELECT unit.* FROM unit
LEFT JOIN activity ON unit.dialup_user = activity.dialup_user
                  AND !(activity.event_time_unix ...)
                  AND unit.status = 'Active'
WHERE activity.dialup_user IS NULL;

--Greg Johnson

                -----Original Message-----
                From:   Bryan Hunt [mailto:[EMAIL PROTECTED]]
                Sent:   Monday, February 12, 2001 11:10 AM
                To:     [EMAIL PROTECTED]
                Subject:        Can anyone suggest a more efficient method

                I have two tables, one contains units one contains activity
                I run this query ......

                select unit.dialup_user, unit.address1,   activity.dialup_user
                from unit
                LEFT JOIN activity ON
                (unit.dialup_user = activity.dialup_user)
                where  !(activity.event_time_unix > (981990589  -   (2*  ( 24 * (60 *
                60) ) )     )       )  && unit.status ="Active"
                GROUP BY unit.id

                What I am trying to do is select every unit that does not have an 
entry in
                the activity table after a certain unix time.
                Any help would be much appreciated


                Here is the output from the explain command
                table     type    possible_keys  key      key_len  ref      rows
                Extra
                -----    ----     -------------    ---       -------   ---      ----   
     
                       -----
                unit      ALL    NULL NULL  NULL NULL    840     where used;  Using
                temporary
                activity ALL    NULL NULL  NULL NULL    29109 where used

                (2 row(s) affected)


                Bryan Hunt
                Developer
                Netnote Inc


                ---------------------------------------------------------------------
                Before posting, please check:
                   http://www.mysql.com/manual.php   (the manual)
                   http://lists.mysql.com/           (the list archive)

                To request this thread, e-mail <[EMAIL PROTECTED]>
                To unsubscribe, e-mail 
<[EMAIL PROTECTED]>
                Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to