Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Copy column

by JimJx (Beadle)
on Oct 01, 2007 at 21:13 UTC ( [id://641995]=perlquestion: print w/replies, xml ) Need Help??

JimJx has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Copy column
by Joost (Canon) on Oct 01, 2007 at 21:24 UTC
    Did you mean to put "" quotes around that statement?

    I think you need to specify the columns explicitly for something like this to work. Also you may want to be careful about the kind of quotes you're using (and you may not need any, if your columns and tables aren't named after keywords). So how about

    "INSERT INTO $db.$table SELECT '',category,''.'' FROM $db.$oldtable"
    Note that I'm assuming you don't need anything BUT the category from the $oldtable.

    update: usually if "things don't work" there are error messages. Check your database log and the output of your perl program. This is part of a perl program, yes?

    update2: please don't just erase your question and replace it with an answer that doesn't even do what you're asking.

Re: Copy column
by philcrow (Priest) on Oct 01, 2007 at 21:23 UTC
Re: Copy column
by jeanluca (Deacon) on Oct 01, 2007 at 21:26 UTC
    I'm not sure what you're trying, is that perl!
    Have a look at the Mysql manual (http://dev.mysql.com/doc/refman/5.0/en/insert-select.html)
    Here is an attempt of what I think you're trying
    my $sql = "INSERT INTO $db.$table (category) SELECT $oldtable.category + FROM $oldtable" ;
    If this isn't what you're looking for! please ignore me :-)

    Cheers
    LuCa
Re: Copy column
by atemon (Chaplain) on Oct 02, 2007 at 06:54 UTC

    Your update made all other reply invalid and we need to guess your original question. Please revert the node and put your original questions back and add current comments as either a new node or under label "Update"

    Your new comment is :


    Greetings Monks,

    Never mind, I found the answer....

    update table set column12 = column1

    However, I did notice something in the table..... My keywords column has a trailing ',' at the end of it. Is there any way to get rid of this? I know that it probably will not affect the column for searching or anything like that, it is just an aesthetic thing.

    Thanks!
    Jim


    Update:
    In this new comment you say that you have some prob with ','. How shall we answer without knowing the original question?

    Cheers !

    --VC

Re: Copy column
by Gangabass (Vicar) on Oct 02, 2007 at 04:58 UTC

    Can you show your Perl code?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://641995]
Approved by Joost
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2024-04-19 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found