ManuAdam Posted September 3, 2009 Share Posted September 3, 2009 Please help me! For many days I have been trying the sql query to INSERT data from one table to another in the same database, but everytime I am getting this error message: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'fulltext) VALUES(SELECT title, description, article_text FROM jos_a3000_article' at line 1. My problem: I have to insert data from table: jos_a3000_articles That has columnheads like: (id, cat_id, title, description, article_text, pub_date, hash) into another table jos_content That has columnheads (`id`, `title`, `title_alias`, `introtext`, `fulltext`, `state`, `sectionid`, `mask`, `catid`, `created`, `created_by`, `created_by_alias`, `modified`, `modified_by`, `checked_out`, `checked_out_time`, `publish_up`, `publish_down`, `images`, `urls`, `attribs`, `version`, `parentid`, `ordering`, `metakey`, `metadesc`, `access`, `hits`, `metadata` ) I tried sql query like: INSERT INTO jos_content (title,introtext,fulltext) SELECT title, description, article_text FROM jos_a3000_articles; It failed. Then I tried: INSERT INTO jos_content(title, introtext, fulltext) VALUES("SELECT title, description, article_text FROM jos_a3000_articles") That again showed the syntax error. Please help where am I making mistakes and what should be the right query in such case of mismatched columns. And specially , if I want to put all the content from jos_a3000_articles into a particular section of jos_content.. what should be the right Query. I would be highly obliged for your kind expert's help. Thanking you. Link to comment https://forums.phpfreaks.com/topic/172943-plz-help-for-right-syntax-of-sql-query/ Share on other sites More sharing options...
avvllvva Posted September 3, 2009 Share Posted September 3, 2009 Try INSERT ... SELECT http://dev.mysql.com/doc/refman/5.0/en/insert-select.html Link to comment https://forums.phpfreaks.com/topic/172943-plz-help-for-right-syntax-of-sql-query/#findComment-911487 Share on other sites More sharing options...
kickstart Posted September 3, 2009 Share Posted September 3, 2009 Hi What error do you get from this:- INSERT INTO jos_content (title,introtext,fulltext) SELECT title, description, article_text FROM jos_a3000_articles; The other 2 attempts will cause errors. One because I think it will assume that you are trying to put "SELECT title" into the first column, "description" into the 2nd and "article_text FROM jos_a3000_article" into the third. The other because you are trying to insert the string "SELECT title, description, article_text FROM jos_a3000_articles" into the first column without specifying values for the 2nd and 3rd columns. All the best Keith Link to comment https://forums.phpfreaks.com/topic/172943-plz-help-for-right-syntax-of-sql-query/#findComment-911489 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.