Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

proper syntax?? HELP

Status
Not open for further replies.

shamrox

Programmer
Sep 27, 2001
81
US
I keep getting a syntax error. Can you someone tell me what's wrong here.

Code:
SELECT employee_time.eid, ids_oa.oa_name, employee_time.req_num, employee_time.num_hrs, ids_worktype.worktype, employee_time.`date`, employee_time.num_of_changes, employee_time.comments
FROM employee_time
WHERE employee_time.`date`>= 'startdate' AND employee_time.`date` <= 'enddate'  AND employee_time.eid = 'analyst' 
JOIN ids_oa ON employee_time.oaid=ids_oa.oaid
JOIN ids_worktype ON employee_time.work_type=ids_worktype.wid

 
Joins come BEFORE where clauses.
[tt]
SELECT employee_time.eid
, ids_oa.oa_name
, employee_time.req_num
, employee_time.num_hrs
, ids_worktype.worktype
, employee_time.`date`
, employee_time.num_of_changes
, employee_time.comments
FROM employee_time JOIN ids_oa
ON employee_time.oaid=ids_oa.oaid JOIN ids_worktype
ON employee_time.work_type=ids_worktype.wid
WHERE employee_time.`date`>= 'startdate' AND
employee_time.`date` <= 'enddate' AND
employee_time.eid = 'analyst'
[/tt]

Also, not sure why you're testing a date field against a string with "startdate" and "enddate" as a value...

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
I'm trying to output a list of jobs a particular analyst did between the start and end date. But I have to output data from those other tables too, hence the joins. At least that's how I thought it was suppposed to work.

I tried your code changes and it still doesn't pull the correct oa_name from the ids_oa table.
The employee_time table has an id called oaid, that matches an id in the oa_name table. How do i get this to match in the output?

Thanks for you assistance.

 
But you no longer get a syntax error, correct?

It's hard to assist any further without sample data.

*cLFlaVA
----------------------------
Lois: "Peter, you're drunk!"
Peter: "I'm not drunk, I'm just exhausted from stayin' up all night drinking!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top