Give this a try. I used table aliases out of habit.
SELECT table1.id FROM table1 A
LEFT JOIN table2 B ON A.UserName = B.username
AND B.Group != 'Dedicated'
WHERE B.username IS NULL
AND A.StopTime = 0;
- Scott
> 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
>
>
--
--------------------------------------
Scott A. Gerhardt P.Geo.
Gerhardt Information Technologies
[EMAIL PROTECTED]
--------------------------------------
---------------------------------------------------------------------
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