If you are just trying to copy data from one table to another one
(with the same set of columns), you can do it this way:

my $statement = "INSERT INTO selecttable (SELECT * FROM table WHERE language = 
english)" ;

eval { $dbi->do($statement); };  # or prepare and execute



-----Original Message-----
From: Vinnie Lima [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 05, 2003 9:26 AM
To: Anthony Ward
Cc: [EMAIL PROTECTED]
Subject: Re: Insert Statment



A SELECT statement usually looks like this:

<start>
$sth = $connect->prepare("SELECT userid FROM table WHERE language = ?") ;
$sth->execute("english") ;
<end>

A INSERT statement usually looks like this:

<start>
$sth = $connect->prepare("INSERT INTO tablename (column1, column2) VALUES
(?, ?)") ;
$sth->execute("value1", "value2") ;
<end>

What are you trying to do?

Are you trying to insert a SELECT statement in a field of a column?  If so,
try this:

<start>
$statement = "SELECT userid FROM table WHERE language = english" ;
$sth = $connect->prepare("INSERT INTO selecttable (query) VALUES (?)") ;
$sth->execute($statement) ;
<end>

These statements are from the top of my head for mysql so you should verify
the syntax at your database vendor's website.

v.


----------------------------------------------------------------------------------------

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------




|---------+--------------------------->
|         |           "Anthony Ward"  |
|         |           <awards         |
|         |           @wanadoo.fr>    |
|         |                           |
|         |           06/05/03 09:55  |
|         |           AM              |
|         |                           |
|---------+--------------------------->
  
>---------------------------------------------------------------------------------------------------------------|
  |                                                                                    
                           |
  |        To:      Vinnie Lima/CEG/[EMAIL PROTECTED]                                  
                                     |
  |        cc:                                                                         
                           |
  |        Subject: Re: Insert Statment                                                
                           |
  
>---------------------------------------------------------------------------------------------------------------|




Why is it not correct (and i also made a typo)!

INSERT INTO selecttable values(?)
$sth->execute(SELECT userid FROM table WHERE language = english);
I can't see the error

can you please explain
thanx
Anthony







> "INSERT INTO selecttable values(SELECT FROM table WHERE language=
english)"
>
> Which is incorrect.
>
> v.
>
>
>
--------------------------------------------------------------------------
--------------
>
> This is a PRIVATE message. If you are not the intended recipient, please
> delete without copying and kindly advise us by e-mail of the mistake in
> delivery. NOTE: Regardless of content, this e-mail shall not operate to
> bind CSC to any order or other contract unless pursuant to explicit
written
> agreement or government initiative expressly permitting the use of e-mail
> for such purpose.
>
--------------------------------------------------------------------------
--------------
>
>
>
>
> |---------+--------------------------->
> |         |           "anthony"       |
> |         |           <awards         |
> |         |           @wanadoo.fr>    |
> |         |                           |
> |         |           06/05/03 09:14  |
> |         |           AM              |
> |         |                           |
> |---------+--------------------------->
>
>
---------------------------------------------------------------------------
------------------------------------|
>   |
|
>   |        To:      [EMAIL PROTECTED]
|
>   |        cc:
|
>   |        Subject: Insert Statment
|
>
>
---------------------------------------------------------------------------
------------------------------------|
>
>
>
>
> Hi,
>
> is it possible if I have
> $a="SELECT FROM table WHERE language= english";
>
> and I want to put the statment as text into the database like so
> INSERT INTO selecttable values(?);
> $sth->execute($a);
> I'm getting an error so maybe it is not possible. Any help is
appreciated.
> Anthony
>
>
>
>
>
>
>
>







Reply via email to