Get data from MySql table and store into array then write to antoher table
I need to write a script that will process a few MySql queries, store the results, then write the results to another MySql table. I then need this to run on my CentOS server as a cron job daily.
Thanks
PHPMySQL ServerLinux
Last Comment
johanntagle
8/22/2022 - Mon
johanntagle
Can you be more specific? What are your queries? Store the results where, besides the other MySQL table? What's the structure of the tables involved?
If the requirement is simple enough and you really need to just store to another table it may be possible to just have an SQL file that contains something like:
insert into new_table (col1, col2, col3, col4) select a, b, c, d from table1 join table2....
Then just call have cron call: mysql -u username --password=yourpassword databasename < file.sql (or have put that in a shell script and have cron call that instead)
ipconfig610
ASKER
I basically want to run a few SELECT COUNT statements and store the results in another table since the counts change daily.
Example:
SELECT count(*) from database1.extensions;
I then want to write the count result to another table. The other table will only have 3 fields, company name, date, and the result from the SELECT.
If the requirement is simple enough and you really need to just store to another table it may be possible to just have an SQL file that contains something like:
insert into new_table (col1, col2, col3, col4) select a, b, c, d from table1 join table2....
Then just call have cron call: mysql -u username --password=yourpassword databasename < file.sql (or have put that in a shell script and have cron call that instead)