Question : MSSQL OR within many AND's

Evening ladies!

My head is frying today, its a Friday so heck, lets ask some other fellow developers :)

Below is a SQL query I'm working on with SCCM, I need to pull back all of the AND's and then i need to know if it is either Photoshop or Illustrator. Unfortunately the way the query works i not how i Want because I also need to know if they are newer than that certain time stamp but unfortunaly it pulls back older ones because they have illustrator in them.
Any ideas?

Cheers,
steve

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
SELECT     sms_ncs.dbo.v_MeterData.TimeSerial, sms_ncs.dbo.v_MeterData.Started, sms_ncs.dbo.v_MeterData.Released, sms_ncs.dbo.v_MeterData.StillRunning, sms_ncs.dbo.v_SoftwareFile.FileName, 
                      sms_ncs.dbo.v_R_System.Name0, sms_ncs.dbo.v_R_System.SMS_Unique_Identifier0, sms_ncs.dbo.v_MeteredUser.FullName, sms_ncs.dbo.v_MeteredUser.UserName, sms_ncs.dbo.v_MeterData.EndTime
FROM         sms_ncs.dbo.v_SoftwareFile INNER JOIN
                      sms_ncs.dbo.v_MeterData ON sms_ncs.dbo.v_SoftwareFile.FileID = sms_ncs.dbo.v_MeterData.FileID INNER JOIN
                      sms_ncs.dbo.v_R_System ON sms_ncs.dbo.v_MeterData.ResourceID = sms_ncs.dbo.v_R_System.ResourceID INNER JOIN
                      sms_ncs.dbo.v_MeteredUser ON sms_ncs.dbo.v_MeterData.MeteredUserID = sms_ncs.dbo.v_MeteredUser.MeteredUserID
WHERE     (sms_ncs.dbo.v_MeterData.Released = '0') AND (sms_ncs.dbo.v_MeterData.StillRunning = '1') AND 
                      ((sms_ncs.dbo.v_SoftwareFile.FileName = 'Photoshop.exe') OR
                      (sms_ncs.dbo.v_SoftwareFile.FileName = 'illustrator.exe'))

Answer : MSSQL OR within many AND's

you need to add () around the OR ---
you should also start using table aliases:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
SELECT md.TimeSerial
     , md.Started
     , md.Released
     , md.StillRunning
     , sf.FileName
     , s.Name0
     , s.SMS_Unique_Identifier0
     , mu.FullName
     , mu.UserName
     , md.EndTime
FROM  sms_ncs.dbo.v_SoftwareFile sf
INNER JOIN sms_ncs.dbo.v_MeterData md
   ON sf.FileID = md.FileID 
INNER JOIN sms_ncs.dbo.v_R_System s
  ON md.ResourceID = s.ResourceID 
INNER JOIN sms_ncs.dbo.v_MeteredUser mu
  ON md.MeteredUserID = mu.MeteredUserID
WHERE md.Released = '0'
  AND md.TimeSerial > '1279105480'
  AND md.StillRunning = '1'
  AND (  sf.FileName = 'Photoshop.exe'
      OR sf.FileName = 'illustrator.exe' 
      )
Random Solutions  
 
programming4us programming4us