PHP MySQLi在'where doi ='附近插入Errno 1064

时间:2018-07-10 15:29:38

标签: php mysql

我意识到以前曾问过类似的问题,有些没有回答,但是尝试了每个被接受的答案之后,我在“看到”我的语法错误方面就没有前进了。在过去的两个小时里,我一直在移动单引号和双引号,但无济于事,我需要换一个角度来看。这是我的PHP / MYSQL字符串:

$sql_2 = "INSERT INTO program_tracking_datalake.altmetric_daily SET doi='" . $remote_doi . "',alt_wikipedia_mentions='" . $wiki  . "',alt_video_mentions='" . $video . "',alt_tweet_mentions='" . $tweet . "',alt_syllabus_mentions='" . $syllabus . "',alt_rdt_mentions='" . $rdt . "',alt_qna_mentions='" . $qna  . "',alt_policy_mentions='" . $policy . "',alt_pinterest_mentions='" . $pinterest . "',alt_peer_review_mentions='" . $peer . "',alt_msm_mentions='" . $msm . "',alt_linkedin_mentions='" . $linkedin . "',alt_gplus_mentions='" . $gplus . "',alt_fbwall_mentions='" . $fbwall . "',alt_f1000_mentions='" . $f1000 . "',alt_blog_mentions='" . $blog . "',alt_historical_mentions_1d='" . $oneDay . "',alt_historical_mentions_3d='" . $threeDay . "',alt_historical_mentions_1w='" . $oneWeek . "',alt_historical_mentions_1m='" . $oneMonth . "',alt_historical_mentions_3m='" . $threeMonth . "',alt_historical_mentions_6m='" . $sixMonth . "',alt_historical_mentions_1y='" . $oneYear . "',alt_historical_mentions_at='" . $allTime . "',alt_pubmed_id='" . $outputs['data'][$j]['attributes']['identifiers']['pubmed-ids'][0] . "'  where doi='".$local_doi."'";

1 个答案:

答案 0 :(得分:2)

您正在混合使用UPDATE和INSERT语法:

UPDATE table set col='val',col2='val2' where id='3';

INSERT INTO table (col, col2) VALUES ('val', 'val2');

插入语句不带有“ where”子句。

更新: 您可以使用“设置”样式插入,但是除非进行某些INSERT ... SELECT操作,否则仍然不能使用“ where col = val”,但是由于某些未知原因,您可以使用“ where 1”。

INSERT INTO table set col='val',col2='val2';