在mysql内部形成一个子查询?

问题描述:

列出具有与客户编号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

确定 - 我收回我接近的选票,它看起来像你有一个答案。 –

你需要约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

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