0
我有一個像下面這樣的查詢。如圖所示它有一個子查詢。我想要的是使where
子句的值應該基於s1.id
。目前,我讓靜態2
因爲我已經試過where s2.id = s1.id
,它不是工作:sql查詢中Where子句的值是選擇的父列
SELECT
s1.id,
s1.code,
(SELECT
c.company_name
FROM
company c
INNER JOIN
(SELECT
a.company_id
FROM
agent a
INNER JOIN shop s2 ON a.id = s2.agent_id
WHERE
s2.id = 2) AS agent_shop ON agent_shop.company_id = c.id) AS agent_company_name
FROM
shop s1
有沒有辦法實現呢?