PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.databases.mysql > Problems with insert...select
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Problems with insert...select

Réponse
 
LinkBack Outils de la discussion
Vieux 01/10/2007, 11h20   #1
mcastell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Problems with insert...select

Hello,

I have a problem in running an "insert..select" command to move data
from one table to another. Namely, I have this two tables in my
database, say "table1" and "table2", with a certain number of columns,
among which:

======
table1
======
....
author
title
journal
link_ref
adslink
linkimage
....

======
table2
======

....
authors
title
journal
cmdiagrams
adslink
linkima
....

and I try to run this command (via SQL box into phpMyAdmin):

$ insert into table2
(authors,title,journal,cmdiagrams,adslink,linkima)
select (author,title,journal,link_ref,adslink,linkimage)
from table1;

but I obtain the following error code:
#1241 - Operand should contain 1 column(s)

Admittedly, I can't understand what is the problem with the columns..
Could anyone give me a hint?

(i've checked the mysql online manual, but I was not able to find more
info..)

Thanks in advance for any .

Marco C.

  Réponse avec citation
Vieux 01/10/2007, 12h27   #2
Captain Paralytic
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problems with insert...select

On 1 Oct, 11:20, mcastell <mcas...@gruppolocale.it> wrote:
> Hello,
>
> I have a problem in running an "insert..select" command to move data
> from one table to another. Namely, I have this two tables in my
> database, say "table1" and "table2", with a certain number of columns,
> among which:
>
> ======
> table1
> ======
> ...
> author
> title
> journal
> link_ref
> adslink
> linkimage
> ...
>
> ======
> table2
> ======
>
> ...
> authors
> title
> journal
> cmdiagrams
> adslink
> linkima
> ...
>
> and I try to run this command (via SQL box into phpMyAdmin):
>
> $ insert into table2
> (authors,title,journal,cmdiagrams,adslink,linkima)
> select (author,title,journal,link_ref,adslink,linkimage)
> from table1;
>
> but I obtain the following error code:
> #1241 - Operand should contain 1 column(s)
>
> Admittedly, I can't understand what is the problem with the columns..
> Could anyone give me a hint?
>
> (i've checked the mysql online manual, but I was not able to find more
> info..)
>
> Thanks in advance for any .
>
> Marco C.


You can't have looked very hard then. The section entitled "INSERT ...
SELECT Syntax"
(http://dev.mysql.com/doc/refman/5.0/...rt-select.html)

shows the syntax of an INSERT SELECT command (amazing huh!) and gives
an example at the very top of the page.

Your query doesn't look like the example.

  Réponse avec citation
Vieux 01/10/2007, 14h05   #3
mcastell
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Problems with insert...select

On 1 Ott, 13:27, Captain Paralytic <paul_laut...@yahoo.com> wrote:

> (...)
> Your query doesn't look like the example.


Ops, thanks a lot! I did check the quoted page several times, but
still I had not understood that I could NOT have the brackets
following the select... my fault!

Greetings,

Marco

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 19h59.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08131 seconds with 11 queries