MySQL - 错误代码:1054。'on子句'中的未知列'task_log_wip.task_log_task'

时间:2017-06-05 13:49:15

标签: mysql

我的查询有点奇怪。此查询有效:

SELECT task_log_wip.*
FROM task_log_wip
INNER JOIN tasks ON tasks.task_id = task_log_wip.task_log_task;

但是这个查询不起作用:

SELECT task_log_wip.*, xmlform.*
FROM task_log_wip, xmlform
INNER JOIN tasks ON tasks.task_id = task_log_wip.task_log_task;

向SELECT和FROM添加任何类型的表将产生以下错误:

错误代码:1054。'on clause'中的未知列'task_log_wip.task_log_task'

task_log_wip 结构:

task_log_id
task_log_task
task_log_name
task_log_description
task_log_creator
task_log_hours
task_log_date
task_log_costcode
task_log_xmlform_id
task_log_xmldoc
task_log_uniqueid
task_log_javascript_executed
task_log_fm_related_date
task_log_draft
task_log_status
task_log_approver
task_log_approval_date
task_log_pre_delete_status
task_log_deletion_approver
task_log_deletion_date
task_log_orig_creator
task_log_wip_auto_save
task_log_orig_created

任务结构:

task_id
task_name
task_parent
task_milestone
task_project
task_owner
task_start_date
task_duration
task_duration_type
task_hours_worked
task_end_date
task_status
task_priority
task_percent_complete
task_description
task_target_budget
task_related_url
task_creator
task_order
task_client_publish
task_dynamic
task_access
task_notify
task_departments
task_contacts
task_custom
task_xmlform_id
task_procedure
task_virtual
task_ypaccess
task_created_ts

xmlform 结构( task_log_wip 通过task_log_wip_xmlform_ id xmlform 相关联):

xmlform_id
xmlform_project_type
xmlform_project_type_parent
xmlform_type
xmlform_name
xmlform_description
xmlform_dtd
xmlform_edit_rule_value
xmlform_company_id
xmlform_department
xmlform_creator_id
xmlform_shared
xmlform_notify_via_email
xmlform_notify_via_sms
xmlform_notify_via_pager
xmlform_notify_via_instant_messenger
xmlform_report_severity_level
xmlform_hidden
xmlform_released
xmlform_restricted
created_by
created_timestamp
last_updated_by
last_updated_timestamp

1 个答案:

答案 0 :(得分:1)

所以你需要使用xmlform表来加入JOFT或LEFT JOIN:

SELECT task_log_wip.*, 
       xmlform.*
 FROM task_log_wip
       INNER JOIN tasks 
          ON tasks.task_id = task_log_wip.task_log_task
       INNER JOIN xmlform
          ON xmlform.id = task_log_wip.task_log_wip_xmlform_id;

JOIN或LEFT JOIN选项取决于您的数据和要求。