gpt4 book ai didi

mysql - 顺序子句中的列 'task_id' 不明确

转载 作者:太空宇宙 更新时间:2023-11-03 12:14:36 25 4
gpt4 key购买 nike

    SELECT a.*, p.*, t.*, r.*, n.* 
FROM prop_assigns AS a
LEFT JOIN properties AS p
ON (p.property_id = a.property_id)
LEFT JOIN tasks AS t ON (t.task_id = a.task_id)
LEFT JOIN reminders_tasks AS r ON (a.assign_id = r.assign_id)
LEFT JOIN notes_view AS n ON (p.property_id = n.property_id)
WHERE a.user_id = 3 AND a.task_id <> 0 AND
a.assign_done = 0 AND n.user_id = 3 ORDER BY task_id desc

MySQL 回应:文档

#1052 - Column 'task_id' in order clause is ambiguous

看起来很长的sql有什么帮助

最佳答案

字段task_id 在多个表中。您需要具体说明您的意思:

SELECT a.*, p.*, t.*, r.*, n.*
FROM prop_assigns AS a LEFT JOIN
properties AS p
ON (p.property_id = a.property_id) LEFT JOIN
tasks AS t
ON (t.task_id = a.task_id) LEFT JOIN
reminders_tasks AS r
ON (a.assign_id = r.assign_id) LEFT JOIN
notes_view AS n
ON (p.property_id = n.property_id)
WHERE a.user_id = 3 AND a.task_id <> 0 AND a.assign_done = 0 AND n.user_id = 3
ORDER BY t.task_id desc;
---------^

关于mysql - 顺序子句中的列 'task_id' 不明确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22752697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com