Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 simple sub query question

Author  Topic 

lcsgeek
Starting Member

38 Posts

Posted - 2005-04-14 : 12:58:19
I have 3 tables tblAssignments, tblAssignmentAttributes, tblAttributes. A given Assignement may have many Attributes and that list is stored in the many-to-many table tblAssignementAttributes. I need an SQL statement that selects all assignments for a given date that don't have an attribute value of "E". Can anyone assist me? Here's my first go at it, I know its pathetic:

SELECT *
FROM tblAssignments
WHERE ((dueDate) = 10/10/2004) AND
((SELECT * FROM tblAssignmentAttributes WHERE ((assignmentID) = @curAssingmentID) NOT IN('E'))

thanks in advance.

X002548
Not Just a Number

15586 Posts

Posted - 2005-04-14 : 13:22:23
The DDL of the tables would be helpful here if you post them...

Bute here's a shot in the dark




SELECT *
FROM tblAssignments o
WHERE dueDate = 10/10/2004
AND NOT EXISTS (SELECT * FROM tblAssignmentAttributes i
WHERE o.assignmentID = i.assingmentID
AND i.attribute = 'E')





Brett

8-)
Go to Top of Page
   

- Advertisement -