pbrowne Posted April 30, 2009 Share Posted April 30, 2009 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! Link to comment https://forums.phpfreaks.com/topic/156223-consolidate-data-from-multiple-mysql-tables/ Share on other sites More sharing options...
Mchl Posted April 30, 2009 Share Posted April 30, 2009 http://dev.mysql.com/doc/refman/5.0/en/union.html Link to comment https://forums.phpfreaks.com/topic/156223-consolidate-data-from-multiple-mysql-tables/#findComment-822480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.