Missing Operator Error- need second pair of eyes to catch it

Margarita

Registered User.
Local time
Today, 15:23
Joined
Aug 12, 2011
Messages
185
Hello,
This is most likely going to be the silliest thread in this forum- but for the life of me, I cannot see what is causing a 'syntax error- missing operator' error in this query. All the table and field names are correct, as far as I can tell all the commas are in place and I just checked the placement of all the parentheses for the hundredth time. I can't see anything wrong with the syntax. Would someone please be able to take an objective look at this query and let me know if they spot anything off in the syntax?
I normally refrain from posting about simple syntax errors because they should really be resolved independently, but I've been staring at this code for so long now, I feel like I need an outside view to help me out. Thank you so much!

PHP:
SELECT LastName, FirstName, max(RoleStartDate) AS MaxRoleStartDate, LeaveStartDate, LeaveEndDate
FROM (Select * from EMPLOYEE_REG
WHERE 
((EMPLOYEE_REG.RegStartDate is Null Or len(employee_REG.regstartdate)=0 Or EMPLOYEE_REG.RegStartDate<=[end date]))
And 
((EMPLOYEE_REG.EndDate is Null Or len(employee_REG.enddate)=0 Or EMPLOYEE_REG.EndDate>= [start date]))
and 
(
(    (leavestartdate is null or len(leavestartdate)= 0) and (leaveenddate is null or len(leaveenddate)=0)     ) 
or 
(leaveenddate<= [start date])
or
(leavestartdate>=[end date])
or
(leavestartdate betweeen [start date] and [end date])
or 
(leaveenddate between [start date] and [end date])
)
and 
(rolestartdate<= [end date] or rolestartdate is null or len(rolestartdate)= 0)
) 
GROUP BY LastName, FirstName, LeaveStartDate, LeaveEndDate
ORDER BY lastname, firstname;
 
Don't be embarrassed one's own syntax errors can be the hardest thing to find as we read what we expect to have written.

Happy to have helped

Brian
 
A much better way of fighting syntax errors is to use the query designer. Putting something complex together, without verifying each bit , seems fast but then you wind up with errors of various kinds .And because the lot is complex, you start searching for where/what.

If you concoct something complex that fails, then de-concoct it. Build it up bit by bit in the query designer, verifying each step. Once you have the big working chunk, you can paste the SQL into another previously verified chunk.

In this way you always know in which area to look for errors.
 

Users who are viewing this thread

Back
Top Bottom