-3
SELECT m_name, m_status, p_num, p_date, g_code GROUP_CONCAT(g_code)
  FROM  (SELECT D.m_name, D.m_status, A.p_num, A.p_date, C.g_code 
           FROM post A 
                   LEFT OUTER JOIN postgoods B 
                          ON A.p_num = B.p_num
                   LEFT OUTER JOIN goodscode C 
                          ON B.g_num = C.g_num JOIN member D ON A.m_num = D.m_num
         ORDER BY A.p_date desc)
GROUP BY p_num

不知这段代码是否出错

4

1 回答 1

1

你在这里少了一个逗号

SELECT ... g_code, GROUP_CONCAT(g_code)
                 ^

编辑

您还缺少子选择的表别名(我将其命名为z)。尝试

SELECT m_name, m_status, p_num, p_date, g_code, GROUP_CONCAT(g_code)
FROM  (SELECT D.m_name, D.m_status, A.p_num, A.p_date, C.g_code 
       FROM post A 
       LEFT OUTER JOIN postgoods B ON A.p_num = B.p_num
       LEFT OUTER JOIN goodscode C ON B.g_num = C.g_num 
       JOIN member D ON A.m_num = D.m_num
       ORDER BY A.p_date desc) z
GROUP BY p_num

您可以使用 MySQL Workbench 来运行您的查询。这是免费的。它将输出您查询的错误。

于 2012-07-19T07:53:27.737 回答