laziness, impatience, and hubris PerlMonks

### Copy column

 on Oct 01, 2007 at 21:13 UTC Need Help??
JimJx has asked for the wisdom of the Perl Monks concerning the following question:

Greetings Monks,

Never mind, I found the answer....


update table set column12 = column1

[download]

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

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"
[download]
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" ;
[download]
If this isn't what you're looking for! please ignore me :-)

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

Greetings Monks,

Never mind, I found the answer....


update table set column12 = column1
[download]

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?

Create A New User
Node Status?
node history
Node Type: perlquestion [id://641995]
Approved by Joost
help
Chatterbox?
 [thezip]: Is there an analogy for '&' (ie. run commandline process in background) for Windows commandline? [Corion]: thezip: start "some title" path\to\that\ application, but that will open another console window [Corion]: thezip: If you want to confuse your users, use system(1, "that\\command" );, which will make Perl launch it in the background [Corion]: That will keep the console window open even though the user can't type into it anymore [thezip]: So I have a script that generates a log file. After script completion, I want tohave VIM open this logfile. [thezip]: i don't get the command line "back" until I close VIM. No what I want to happen... [thezip]: I currently don't have access to CYGWIN, else I'd just do a tail -f on the logfile.

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (11)
As of 2017-03-27 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should Pluto Get Its Planethood Back?

Results (321 votes). Check out past polls.