如何编写这样的嵌套查询!!!
Select t1.c1,t1.c2 (select t1.c2-t2.c2 AS abc from t2 where t2.cl=t1.cl1 ), t1.c3 FROM t1
真正的查询是
SELECT
jobc_parts.part_invoice_no,
jobc_parts_p.part_no,
jobc_parts.part_description,
DATE_FORMAT(jobc_parts.issue_time,' %d %b %y') AS issuedate,
(SELECT jobc_parts_p.qty_issued FROM jobc_parts_p WHERE parts_sale_id=
jobc_parts.unitprice,
jobc_parts.total,
p_purch_stock.Price,
p_purch_stock.Invoice_no,
(jobc_parts.issued_qty*p_purch_stock.Price) AS purchase_price,
(jobc_parts.total- (SELECT purchase_price)) AS profit
FROM
`jobc_parts_p`
INNER JOIN p_purch_stock ON jobc_parts_p.Stock_id=p_purch_stock.stock_id
INNER JOIN jobc_parts ON jobc_parts_p.parts_sale_id=jobc_parts.parts_sale_id
WHERE
jobc_parts.STATUS= '1' AND DATE_FORMAT(jobc_parts.issue_time, '%Y-%m-%d') BETWEEN '2018-09-25' AND '2018-09-25' AND part_invoice_no=1184