perl mysql question
Not sure if I should post this to beginners or not but there it goes. I have 10+ tables with some of the same information in each in table of a mysql database. Here is an example: Table 1 namecount -+--- Widgets-A| 10 Widgets-B| 5 Widgets-C| 10 Widgets-D| 5 Widgets-E| 15 Table 2 namecount -+--- Widgets-A| 15 Widgets-B| 5 Widgets-C| 10 Table 3 namecount -+--- Widgets-D| 5 Widgets-E| 15 I need to take the names and add the counts up for between each table and I am not sure how to make that happen. I would be able to do a select query so that the values are all in one query, like this: namecount -+--- Widgets-A| 10 Widgets-B| 5 Widgets-C| 10 Widgets-D| 5 Widgets-E| 15 Widgets-A| 15 Widgets-B| 5 Widgets-C| 10 Widgets-D| 5 Widgets-E| 15 So, how to I get the values to look like in variable so that I can push them back into a new table: New Table namecount -+--- Widgets-A| 25 Widgets-B| 10 Widgets-C| 20 Widgets-D| 10 Widgets-E| 25 Any ideas? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: perl mysql question
--As of Monday, April 26, 2004 5:30 PM -0700, Christopher Lyon is alleged to have said: So, how to I get the values to look like in variable so that I can push them back into a new table: New Table namecount -+--- Widgets-A| 25 Widgets-B| 10 Widgets-C| 20 Widgets-D| 10 Widgets-E| 25 Any ideas? --As for the rest, it is mine. Sure: create a hash, using field one as the key, and *add* (not insert) the count to the value of each element of the hash. Then store the hash in the database. Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: perl mysql question
On 4/26/2004 11:53 PM, Daniel Staal wrote: --As of Monday, April 26, 2004 5:30 PM -0700, Christopher Lyon is alleged to have said: So, how to I get the values to look like in variable so that I can push them back into a new table: New Table namecount -+--- Widgets-A|25 Widgets-B| 10 Widgets-C| 20 Widgets-D| 10 Widgets-E| 25 Any ideas? --As for the rest, it is mine. Sure: create a hash, using field one as the key, and *add* (not insert) the count to the value of each element of the hash. Then store the hash in the database. Depending on the structure of the application it may be more efficient to let the db handle it by constructing a SQL statement that does a join on the name field and creates a calculated field for the total (a.count + b.count). My SQL is rusty, but it should be pretty easy to construct with a decent reference. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Perl / MySQL Question
In my script, I do the following: I insert x amount of records into a MySQL table, process the information and then delete those records. One of the columns is an autonumber type so it starts at 1 for instance. In my query string I use placeholders. Now sometimes the field which is an autonumber starts out at 1 while other times it starts out at whatever number it left off at. Is that normal? I use the following: # Load into database $query1 = insert into data(USER_ID,NAME,etc) values(NULL,?, ?, ?, ? , ?,?,?,?); $sth1 = $dbh-prepare($query1); $rc1 = $sth1-execute($Name,$etc); TIA -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl / MySQL Question
From the MySQL docs: If you delete the row containing the maximum value for an AUTO_INCREMENT column, the value will be reused with an ISAM, or BDB table but not with a MyISAM or InnoDB table. If you delete all rows in the table with DELETE FROM table_name (without a WHERE) in AUTOCOMMIT mode, the sequence starts over for all table types. So this will depend on your table type and how you do your deletes. http://danconia.org On Mon, 11 Nov 2002 11:07:53 -0800, Jessee Parker [EMAIL PROTECTED] wrote: In my script, I do the following: I insert x amount of records into a MySQL table, process the information and then delete those records. One of the columns is an autonumber type so it starts at 1 for instance. In my query string I use placeholders. Now sometimes the field which is an autonumber starts out at 1 while other times it starts out at whatever number it left off at. Is that normal? I use the following: # Load into database $query1 = insert into data(USER_ID,NAME,etc) values(NULL,?, ?, ?, ? , ?,?,?,?); $sth1 = $dbh-prepare($query1); $rc1 = $sth1-execute($Name,$etc); TIA -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]