나는 출력에 인용 번호, 고객 이름 및 주문 합계를 자세히 설명하는 하나의 행에 가입 하시겠어요 3 개 테이블 ..견적, 주문 및 고객 테이블에 가입 하시겠습니까?
TBL_QUOTATIONS
quotation_id | customer_id | status
-----------------+-----------------+---------------
1038 21 Open
1039 22 Open
TBL_CUSTOMERS
customer_id | name | status
-----------------+-----------------+---------------
21 David Active
22 Alvin Active
TBL_ORDERS
이order_id | quote_id | desc | amount
-------------+--------------+---------------------+-------------
1 1038 Consultation 1500
2 1038 Design Fees 1200
3 1038 Misc Fees 500
도움이 필요하십니까? 현재 내가 INNER는 tbl_quotations.customer_id = tbl_customers.customer_id ON 고객을 가입 tbl_quotations로부터
SELECT tbl_quotations.quote_id, customers.customer_id, 이름, 합계 (양) 를 사용하고 ... 제대로 위를 할 수있는 문을 얻을 수 있습니다 tbl_quotations.quote_id 주문을 가입 =
결과
quote_id | customer_name | sum(amount)
-------------+-------------------+-------------------
1038 David 3200
1039 Alvin 0
. . .
. . .
. . .
을 tbl_orders.quote_id 내가 잘못하지만 분명히 문은 데이터베이스에 더 많은 따옴표를 한 경우에도 하나 개의 행을 반환 어디 확실하지 않다.
내가 잘못 된 부분에 대한 도움이나 조언이 있으십니까? 나의 접근 방식은 심지어 적절한가? 감사합니다.
당신은 tbl_quotations.quote_id'에 의해'GROUP 필요보십시오. – Vatev
감사합니다, 매력처럼 작동합니다! – user3448267