2017-09-23 15 views
-2

列出具有與客戶編號282相同的代表編號的客戶編號,客戶姓名和銷售代表。這將需要是子查詢,並且不要明確測試銷售代表35。讓MySQL爲你做好工作。在此處插入您的查詢和結果。在mysql內部形成一個子查詢?

use premier_products; 

    select customer.customer_num,customer.customer_name,rep.first_name 
    (SELECT rep_num 
    from rep,customer 
    where rep.rep_num = customer.rep_num 
    and customer_num = 282) 
    from customer,rep; 

即時通訊如何與以下問題形成子查詢混淆。兩個表之間相關的唯一兩個fileds是rep.rep_num = customer.rep_num。

和REP.FIRST_NAME指SALES REP ...

+0

我只是試圖得到幫助,我知道我靠近 –

+0

確定 - 我收回我接近的選票,它看起來像你有一個答案。 –

回答

1

你需要約tables Join in MySql研究。

您的查詢並不需要一個子查詢:

SELECT customer.customer_num, customer.customer_name, rep.first_name, rep.rep_num 
FROM rep 
JOIN customer 
ON rep.rep_num = customer.rep_num 
WHERE customer_num = 282; 
+0

是的,但我需要把它放在一個子查詢,所以試圖瞭解如何做到這一點@eventHandler –

+0

你知道如何把它放在子查詢格式 –