I have the following table structure of my db:

  • tbl_project

  • tbl_employee

  • tbl_deliverable

  • user_to_deliverable
    as tbl_prjct and tbl_deliverable has 1-many relation, tbl_employee and tbl_deliverable have many-many relation so they are splited into user_to_deliverable table

All i want is that a query to show project_name(from tbl_project), project's deliverables (from tbl_deliverable) and emloyee name to which that specific deliverable is assigned to.

Can i get help with this?

Recommended Answers

All 3 Replies

Actually, I not quite understand why should you consider to have a join query while you can seperate it into multiple? As based on my understanding, minimizing and made simple query would be better. What I'll do is use single query to get project_name. If the data exist, then the query is run to get extra data. By this way, the inner query will not be run if the data is not exist while on the other hand, the join query will run everything which may prolong the runtime.

*please do correct me if my understanding is wrong.

Guessing at the id's that link your tables and not knowing the WHERE cluase:

"SELECT tbl_project.project_name, tbl_delivarables.deliverables, tbl_employee.employee_name FROM tbl_project INNER JOIN tbl_deliverables ON tbl_deliverables.project_id=tbl_project.project_id INNER JOIN tbl_employees ON tbl_employees.employee_id=tbl_deliverables.employee_id WHERE ........"

LPS: as you said, this is very easy to do but if I do this task in your way,


will be executed at least 4 times which may cause some performance problem and its also not a good practice to send connections to mysql every time?
I have read that in case of huge data, this practice can also lead to crash :( so i will not recomend any body to do that practice.
Hope i am clear now? :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.