mysqli - Table Alias - Multiple Foreign Keys Referring to the Same Table -


i can't figure out how use alias tables (i assume alias right approach problem). have table subcontract 3 fields: subcontractid, divisionmanager , servicemanager. both fields related same table employee through employeeid. table employee includes employeeid , firstname fields. can't figure out how display firstname both divisionmanager , servicemanager @ same time. used approach still not working:

$query = "select subcontract.subcontractid, subcontract.divisionmanageremployeeid, employee.firstname, subcontract.servicemanageremployeeid, employee.firstname subcontract   inner join employee  employee1 on employee1.employeeid = subcontract.divisionmanageremployeeid inner join employee  employee2 on employee2.employeeid = subcontract.servicemanageremployeeid";  $stmt = $db->prepare($query); $stmt->execute(); $stmt->store_result(); $numrows = $stmt->num_rows; $stmt>bind_result($subcontractid,$divisionmanageremployeeid,$divisionmangerfirstname, $servicemanageremployeeid,$servicemangerfirstname); 

any appreciated it.

i figure out:

select subcontract.subcontractid, subcontract.divisionmanageremployeeid,divisionmanager.firstname,  subcontract.servicemanageremployeeid, servicemanager.firstname   subcontract  inner join employee servicemanager on servicemanager.employeeid = subcontract.servicemanageremployeeid inner join employee divisionmanager on divisionmanager.employeeid = subcontract.divisionmanageremployeeid 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -