数据库多表复合连接

时间:2013-12-06 11:24:58

标签: mysql sql select join where

我有3个表和请求,请求条件,客户

请求包含customer_id,它引用customer表id并包含employee_id

requestcondition包含request_id,它引用请求表id

我想根据employee_id

选择请求详细信息和请求条件详细信息以及cutomer

1 个答案:

答案 0 :(得分:0)

试试这个:

SELECT * 
FROM request r 
INNER JOIN customer c ON r.customer_id = c.customer_id
INNER JOIN requestcondition rc ON r.request_id = rc.request_id 
WHERE r.employee_id = 123