Jump to content

Consolidate data from multiple MySQL TABLES


pbrowne

Recommended Posts

I have eight tables with the same schema but containing different data.

`node_a_data` (

`node_a_data_id` int(5) NOT NULL auto_increment,

`timestamp` int(10) NOT NULL default '',

`user_count` int(5) NOT NULL default '0',

PRIMARY KEY (`node_a_data_id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=795 ;

 

The timestamp field just contains a Unix 10 digit timestamp (ie INT(10)) 15 minutes apart for each record in each table, and they will be unique in each table, but only a minute or so apart. What I want to be able to do is group the timestamp records (say in 15 minute segments) and have the user_count summed across the tables for each 'rounded' segment. The PHP code that I have for returning records for an individual table is in the snippet:

 

<?php require_once('connection/connect.php');
mysql_select_db($database, $connection);

$query = "SELECT * FROM node_d_data";
$result = mysql_query($query, $connection) or die(mysql_error());

while($row = mysql_fetch_assoc($result)){  
  $timestamp =  date('d-m-y H:i',$row['timestamp']);
  $users =  $row['user_count'];

  echo "$timestamp;$users\n";
} 

?>

 

I just want to have this modified so that it returns data as described above from the following tables:

 

node_a_data

node_b_data

node_c_data

node_d_data

node_e_data

node_f_data

node_i_data

node_j_data

 

 

Any help appeciated!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.