操作数应包含1个列,用于多个表查询

时间:2017-08-02 09:33:20

标签: php mysql

实际上我将两个多表数据插入到一个表中,我编写了以下查询,我想将两个表中的一些字段插入到新表中。我为我的网站编写了新提交的表单的代码,但我想更新数据库中的现有数据。

请看下面的qyery。 请建议。

下面的查询给了我一个错误:

“操作数应包含1列”

            INSERT INTO am_intranet_hr_lead_document(doc_name,careers_submissions_key,hr_phase_key,response_id,date_added) 
            SELECT (am_career_submissions.resume,am_career_submissions.careers_submissions_key,am_intranet_hr_lead_response.hr_phase_key,am_intranet_hr_lead_response.response_id,am_career_submissions.add_dt) 
            FROM am_career_submissions, am_intranet_hr_lead_response 
            WHERE am_career_submissions.careers_submissions_key = am_intranet_hr_lead_response.careers_submissions_key

谢谢。

1 个答案:

答案 0 :(得分:1)

使用内部连接和限制
喜欢这个

INSERT INTO am_intranet_hr_lead_document(doc_name,careers_submissions_key,hr_phase_key,response_id,date_added) 
           SELECT (am_career_submissions.resume,am_career_submissions.careers_submissions_key,am_intranet_hr_lead_response.hr_phase_key,am_intranet_hr_lead_response.response_id,am_career_submissions.add_dt) 
            FROM am_career_submissions, 
            join am_intranet_hr_lead_response 
            on am_career_submissions.careers_submissions_key = am_intranet_hr_lead_response.careers_submissions_key
            limit 1