hello every one please help me regarding how to make a good query to fetch the data from three table. I am making a database in which there will be users , employee and services which will provided to users via employee so i have set that table name as task. Now i can add the task by fetching the da开发者_如何学Pythonta from different table , the thing right now i want to do is show the entire record by fetching all the client data and services available to him and and who will be going to perform that services . so how can i put the query on the task table to fetch the data from the other table. Thanks
**task table**
task_id user_id employee_id service_id starttime endtime date
by using this table i have to fetch data from other three table by using
user_id employee_id service_id
employee table
employee_id pno name age pic_path
user table
user_id pno name age pic_path
service table
service_id name description
SELECT
t.*,
e.name AS employee_name,
u.name AS user_name,
s.name AS service_name, s.description
FROM tasks AS t
INNER JOIN employees AS e ON e.employee_id = t.employee_id
INNER JOIN users AS u ON u.user_id = t.user_id
INNER JOIN services AS s ON s.service_id = t.service_id
精彩评论