SELECT a.id, a.name, a.ad, c.name, c.phone, c.email,
(
SELECT b.id_user
FROM price_b b
WHERE b.id = a.id
ORDER BY b.date DESC
LIMIT 1
) AS f_user_id
FROM a_emtp a
LEFT JOIN customer c ON
c.id = f_user_id
WHERE a.show = "1"
嗨,为什么要显示此错误:'on clause'
中的未知列'f_user_id'由于
答案 0 :(得分:2)
SELECT a.id, a.name, a.ad, c.name, c.phone, c.email,
(
SELECT b.id_user
as f_user_id
FROM price_b b
WHERE b.id = a.id
ORDER BY b.date DESC
LIMIT 1
)
FROM a_emtp a
LEFT JOIN customer c ON
c.id = f_user_id
WHERE a.show = "1"
您可以引用外部查询中子查询中的带标签字段。您甚至可以删除重新标记,只需使用“b.id_user”。
答案 1 :(得分:0)
可能是c.email丢失后的逗号。
SELECT a.id, a.name, a.ad, c.name, c.phone, c.email,
(
SELECT b.id_user
FROM price_b b
WHERE b.id = a.id
ORDER BY b.date DESC
LIMIT 1
) AS f_user_id
FROM a_emtp a
LEFT JOIN customer c ON
c.id = f_user_id
WHERE a.show = "1"