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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

join question - 3 tables -

Status
Not open for further replies.

hugstable

Programmer
Feb 20, 2006
65
US
this query is working but it cannot be this simple... Pls check it out and see if anything is jumping out at you... I added the cmp_* data - expected it to blow up but it did not...

SELECT DISTINCT
`tbl_job`.`job_id`,
`tbl_job`.`usr_id`,
`tbl_job`.`job_nam`,
`tbl_job`.`job_typ`,
`tbl_job`.`job_des`,
`tbl_job`.`job_nts`,
`tbl_job`.`job_str_dte`,
`tbl_job`.`job_crt_tdt`,
`tbl_job`.`job_upd_tdt`,
`tbl_usr`.`usr_id`,
`tbl_usr`.`cmp_id`,
`tbl_cmp`.`cmp_id`,
`tbl_cmp`.`cmp_nam`,
`tbl_usr`.`usr_nam_fst`,
`tbl_usr`.`usr_nam_lst`
FROM
`tbl_cmp`,`tbl_job`
LEFT OUTER JOIN
tbl_usr
ON tbl_job.usr_id = tbl_usr.usr_id
WHERE
tbl_job.job_id='#job_id#'
AND
tbl_usr.cmp_id = tbl_cmp.cmp_id
 
Code:
  from tbl_job
inner 
  join tbl_usr
    on tbl_usr.usr_id = tbl_job.usr_id
inner
  join tbl_cmp 
    on tbl_cmp.cmp_id = tbl_usr.cmp_id
 where tbl_job.job_id = '#job_id#'
you probably don't need DISTINCT

r937.com | rudy.ca
 
thanks much - will adjust..

just started using joins - very shaky..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top