0

这在 mysql 4 中有效,但在 mysql 5 中无效。在我的新 centos 5.8 服务器 mysql 5.0.95 上的 phpmyadmin 中运行此查询

GIVES: #1054 - Unknown column 'thr.thread_address_id' in 'on clause'

所有表格均已验证。

在网上找到了将值移动到 FROM 子句末尾的建议,但它只是修复了该特定错误并为下一行创建了一个错误。

FROM thread th, address a, address ad, queue q, thread thr, ticket t(解决关于ticket t的警告)

FROM thread th,address a,address ad,queue q,ticket t,thread thr(解决关于thread thr的警告)

SELECT t.ticket_id, t.ticket_subject, t.ticket_priority, t.ticket_spam_trained,
t.last_reply_by_agent, t.ticket_spam_probability, th.thread_date, thr.thread_received,
t.ticket_status, t.ticket_due, th.thread_address_id, t.min_thread_id, a.address_address,
t.ticket_mask, t.ticket_time_worked as total_time_worked, ad.address_address as
requestor_address, ad.address_banned, q.queue_id, q.queue_name ,v_9.field_value as
g_3_custom_9 FROM thread th, address a, address ad, queue q, thread thr, ticket t LEFT
JOIN field_group_values v_9 ON (v_9.entity_index = IF ( v_9.entity_code = 'R',
thr.thread_address_id, t.ticket_id ) AND v_9.field_id = 9) WHERE 1 AND t.max_thread_id =
th.thread_id AND t.min_thread_id = thr.thread_id AND a.address_id = th.thread_address_id
AND ad.address_id = thr.thread_address_id AND q.queue_id = t.ticket_queue_id AND
t.ticket_id IN (172058,172036,172022,172012,171929,171387) GROUP BY t.ticket_id ORDER BY
thr.thread_received DESC
4

1 回答 1

0

您在子句中混合join样式。from您可以通过仅join使用 no来修复查询,

“问题”是 MySQL 在 5.0.12 中进行了更改以更符合 ANSI 语法(您可以阅读文档中的详细信息)。from这改变了子句中逗号周围的范围规则。我是否提到避免在from子句中使用逗号?使用显式连接总是一个好主意。

一个快速的解决方法是将逗号替换为cross join.

于 2013-09-12T22:38:33.970 回答