Jump to content

Plz help for right syntax of sql query


ManuAdam

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.