SELECT t1.id FROM table 1 t1
LEFT JOIN table2 t2 ON t1.UserName = t2.UserName
                   AND t2.Group = 'Dedicated'
                   AND t1.StopTime = 0
WHERE t2.id IS NULL;

--Greg Johnson

                -----Original Message-----
                From:   Drew [mailto:[EMAIL PROTECTED]]
                Sent:   Friday, February 02, 2001 4:00 PM
                To:     [EMAIL PROTECTED]
                Subject:        Efficient Select

                Hi I was wondering if anyone could help me find the most efficient.. or
                at least A efficient way to preform the following task:

                I have a table that has some data, one of which is a UserName column.  
I
                have another table that has multiple rows for that UserName.  So table
                one looks like:

                id              int
                UserName  varchar
                StopTime    datetime

                and table two looks like

                id               int
                UserName   varchar
                Group         varchar

                So far I have 

                SELECT   table1.id
                FROM     table1, table2
                WHERE    table1.StopTime = 0 AND
                               table1.UserName = table2.username AND
                               table2.Group != 'Dedicated'

                You can see that I am trying to get the id's from the first table where
                the stoptime is 0 and they do NOT have an entry in table2 that says
                dedicated.  There are multiple entries is table2 for each username...
                Any suggestions?

                Thanks
                Drew


                ---------------------------------------------------------------------
                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