我正在尋找一個MySQL查詢(使用PHP)的時間和只顯示效果都高於cross_check.lastmodMySQL查詢交叉引用
t_one
不同經歷的每個表一個guid | name | lastmod
1 | Joe | 2012-01-01 01:00:00
2 | Tom | 2012-01-02 01:00:00
3 | Sue | 2012-03-01 02:00:00
t_two
guid | pet | lastmod
4 | cat | 2012-01-01 01:00:00
5 | dog | 2012-01-02 01:00:00
6 | fish | 2012-03-01 02:00:00
t_three
guid | fruit | lastmod
7 | orange | 2012-01-01 01:00:00
8 | pear | 2012-01-02 01:00:00
9 | grape | 2012-03-01 02:00:00
cross_check
guid | lastmod
1 | 2012-01-01 01:00:00
2 | 2012-01-02 01:00:00
3 | 2012-01-01 02:00:00
4 | 2012-01-01 01:00:00
5 | 2012-01-02 01:00:00
6 | 2012-01-01 02:00:00
7 | 2012-01-01 01:00:00
8 | 2012-01-02 01:00:00
9 | 2012-01-01 02:00:00
查詢結果將是:
t_one => 3 | Sue | 2012-03-01 02:00:00
t_two => 6 | fish | 2012-03-01 02:00:00
t_three => 9 | grape | 2012-03-01 02:00:00
到目前爲止我的代碼(需要表交叉引用)
$tables = array('t_one', 't_two', 't_three');
foreach ($tables AS $table) {
$query = sprintf("SELECT * FROM '%s'",
mysql_real_escape_string($table));
$result = mysql_query($query);
}