Link to home
Start Free TrialLog in
Avatar of OhioWoodWright
OhioWoodWright

asked on

SQL Query problems

My query is suppose to search for "Music" in the fields strEventAbstrace or strEventType within the specified date range but it returns records where strEventAbstrace or strEventType contains "Music" from all dates. What am I doing wrong?

SELECT 
      intEventID
     ,dtmEventDateAndTime AS Date
     ,dtmEventDateAndTime AS Time
     ,strEventAbstract AS [Event Description],"
     ,tEventTypes.strEventType AS [Event Type]
     ,strIsOnsite AS [On Campus]
     ,strTransportationProvided AS Transprotation,monCost AS Cost
FROM tEvents
   "INNER JOIN tEventTypes 
      ON tEvents.intEventTypeID = tEventTypes.intEventTypeID
WHERE      strEventAbstract LIKE '%Music%' 
       OR  strEventType Like '%Music%'
       AND dtmEventDateAndTime >= '08/30/2016’ 
       AND dtmEventDateAndTime <= '09/13/2016’ 
ORDER BY dtmEventDateAndTime

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Missus Miss_Sellaneus
Missus Miss_Sellaneus
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, there are double quotes in your query. Not sure if that is intentional.
SELECT 
      intEventID
     ,dtmEventDateAndTime AS Date
     ,dtmEventDateAndTime AS Time
     ,strEventAbstract AS [Event Description]
     ,tEventTypes.strEventType AS [Event Type]
     ,strIsOnsite AS [On Campus]
     ,strTransportationProvided AS Transprotation,monCost AS Cost
FROM tEvents
   INNER JOIN tEventTypes 
      ON tEvents.intEventTypeID = tEventTypes.intEventTypeID
WHERE     (strEventAbstract LIKE '%Music%' 
       OR  strEventType Like '%Music%')
       AND dtmEventDateAndTime >= '20160830' 
       AND dtmEventDateAndTime <= '20160913'
ORDER BY dtmEventDateAndTime

Open in new window