Re: sql question



Hi Terry,


i tried

select o.otrq_emp_clocknum, o.otrq_date, o.otrq_period,
e.emp_clocknum, e.emp_lastname + ', ' + e.emp_firstname as fullname
from otrequests o, otperiodsLkup p
inner join employee e on o.otrq_emp_clocknum = e.emp_clocknum
where p.otp_id = o.otrq_period

this gives a syntax error in join

You are inner joining employee to outrequests, not to otperiodsLkup, so
you query should be:

select o.otrq_emp_clocknum, o.otrq_date, o.otrq_period,
e.emp_clocknum, e.emp_lastname + ', ' + e.emp_firstname as fullname
from otrequests o
inner join employee e on o.otrq_emp_clocknum = e.emp_clocknum,
otperiodsLkup p
where p.otp_id = o.otrq_period

You can also consider this form:

select o.otrq_emp_clocknum, o.otrq_date, o.otrq_period,
e.emp_clocknum, e.emp_lastname + ', ' + e.emp_firstname as fullname
from otrequests o
inner join employee e on o.otrq_emp_clocknum = e.emp_clocknum
inner join otperiodsLkup p on p.otp_id = o.otrq_period

Hope this helps,
Leonid

.



Relevant Pages

  • sql join and lookup table question
    ... using ado and microsoft access ... the otrq_period is an id field from a lookup table ... otp_id, otp_description from otperiodsLkup ... from otrequests o, otperiodsLkup p ...
    (borland.public.delphi.database.ado)
  • sql question
    ... using ado and microsoft access ... the otrq_period is an id field from a lookup table ... otp_id, otp_description from otperiodsLkup ... from otrequests o, otperiodsLkup p ...
    (borland.public.delphi.database.ado)
  • Re: sql join and lookup table question
    ... from otrequests o, otperiodsLkup p ... this gives a syntax error in join ... how do I get the lookup value into the select? ... from otrequests o Inner Join otperiodsLkup p on p.otp_id = o.otrq_period ...
    (borland.public.delphi.database.ado)