1分贝,4桌 . 我必须从表中的项目(table1或table2或table3)获取信息;要搜索的表的名称位于名为“codes”的表中 . 我必须查询此表,然后查询我发现的表...

结构体:

[ codes ]
id  |  table (table = name of table where the id is (in table1, table2 or table3)

[ table1 ]
id  |  info1 | info2 | info3

[ table2 ]
id  |  info1 | info2 | info3

[ table3 ]
id  |  info1 | info2 | info3

我的查询:

$qry = "SELECT * FROM codes ORDER BY id DESC LIMIT 5";
         $result = mysql_query($qry);

         while ($row = mysql_fetch_array($result)) {
            $id = $row['id'];
            $table = $row['table'];

            $qry2 = mysql_query("SELECT * FROM $table WHERE id = '$id'");
            $result2 = mysql_fetch_row($qry2);

            $model              = $result2[1];
            $brand              = $result2[2];

            echo $model . "," . $brand;
            }

这是编码的一个不好的例子 . 我想做这样的事情"metacode":* select * where id(表的)= id(代码)从代码中选择 ED ORDER BY id ASC LIMIT 5 * .