php - mysql query to fetch these results -


i have 3 tables
1.project_ref_table columns
project_id(pk)
project_name
client_id(fk)
project_description

and 2.client_ref_table column
client_id(pk)
client_name
client_email
client_address

3.emp_ref_table
emp_id(pk) emp_name
emp_address
project_id(fk)
dept_id
suppose user login emp_id manager , need fetch client list project this

client_name|client_email|client_address|project_name

you have join 3 tables emp_ref_table, project_ref_table , client_ref_table.

select c.client_name, c.client_email, c.address,p.project_name emp_ref_table e, project_ref_table p, client_ref_table c e.project_id= p.project_id , p.client_id = c.client_id  , e.id = current_user_id 

current_user_id = current manager user id.


Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -