我有一个mysql查询,但是当我正在尝试向我显示该错误时
'字段列表'中的未知列'ps_address.phone_mobile'
Mysql查询
SELECT
ps_orders.id_customer,
ps_customer.firstname,
ps_customer.lastname,
ps_customer.email,
ps_orders.total_paid,
ps_orders.date_add,
ps_address.phone_mobile
FROM
ps_orders JOIN ps_customer on ps_orders.id_customer = ps_customer.id_customer
WHERE ps_address.id_customer=ps_orders.id_customer and
ps_orders.total_paid > 1
AND ps_orders.id_customer IN (
SELECT
ps_orders.id_customer
FROM
ps_orders
GROUP BY
ps_orders.id_customer
HAVING
COUNT(1) < 2
)
答案 0 :(得分:2)
您需要指定您选择FROM的表格。因此,如果列存在,这是更新的查询(缩写):
SELECT
ps_orders.id_customer,
ps_customer.firstname,
ps_customer.lastname,
ps_customer.email,
ps_orders.total_paid,
ps_orders.date_add,
ps_address.phone_mobile
FROM
ps_address, ps_orders
JOIN
ps_customer on ps_orders.id_customer = ps_customer.id_customer
WHERE
ps_address.id_customer=ps_orders.id_customer AND
ps_orders.total_paid > 1 AND
ps_orders.id_customer IN (...)
答案 1 :(得分:0)
该列确实不存在?
您的脚本有语法错误。
中的列名“1”并不存在COUNT(1)&lt; 2
必须为: COUNT( column_name )&lt; 2 或 COUNT(*)&lt; 2
COUNT(ps_orders.id_customer)&lt; 2
答案 2 :(得分:0)
此语法错误表示您在此表“ps_address”中没有此列“phone_mobile”。