时间:2021-07-01 10:21:17 帮助过:5人阅读
用for循环把sql语句包含在里面重复执行,不知道能不能行得通
多次取数据再进行处理吧
$table = array("abc201202","abc201203","abc201204");$result =array();foreach($table as $table_name) { $sql = "select * from ".$table_name; $rec =mysql_query($sql); while($row=mysql_fetch_row($rec)) { $result[] = $row; }}
PHP code
$table = array("abc201202","abc201203","abc201204");
$result =array();
foreach($table as $table_name) {
$sql = "select * from ".$table_name;
$rec =mysql_query($sql);
……
PHP code
$table = array("abc201202","abc201203","abc201204");
$result =array();
foreach($table as $table_name) {
$sql = "select * from ".$table_name;
$rec =mysql_query($sql);
……
$select = array();$table = array("abc201202","abc201203","abc201204");foreach($table as $v) { $select[] = "(select * from $v)";}$sql = join(' UNION ', $select);$res = mysql_query($sql);
$table = array("abc201202","abc201203","abc201204");$result=array();$count = count($table);for ($i=0;$i<$count;$i++){ $sql = $sql." select * from '".$table[$i]."' union all";}$sql=$sql." select * from '".$table[$count]."'";$rec =mysql_query($sql); while($row=mysql_fetch_row($rec)) { $result[] = $row; }
PHP code
$table = array("abc201202","abc201203","abc201204");
$result=array();
$count = count($table);
for ($i=0;$i<$count;$i++){
$sql = $sql." select * from '".$table[$i]."' union all";
}
$s……
PHP code
$select = array();
$table = array("abc201202","abc201203","abc201204");
foreach($table as $v) {
$select[] = "(select * from $v)";
}
$sql = join(' UNION ', $select);
$res = mysql_query……
$table = array("abc201202","abc201203","abc201204");$result=array();$count = count($table)-1;//减去一个数组下标for ($i=0;$i<$count;$i++){ $sql = $sql." select * from '".$table[$i]."' union all";}$sql=$sql." select * from '".$table[$count]."'";$rec =mysql_query($sql); while($row=mysql_fetch_row($rec)) { $result[] = $row; }
PHP code
$table = array("abc201202","abc201203","abc201204");
$result=array();
$count = count($table)-1;//减去一个数组下标
for ($i=0;$i<$count;$i++){
$sql = $sql." select * from '".$table[$i]."' unio……
limit $page $pagesize改成limit $page,$pagesize试试
limit $page $pagesize改成limit $page,$pagesize试试
PHP code
$select = array();
$table = array("abc201202","abc201203","abc201204");
foreach($table as $v) {
$select[] = "(select * from $v)";
}
$sql = join(' UNION ', $select);
$res = mysql_query……
PHP code
$select = array();
$table = array("abc201202","abc201203","abc201204");
foreach($table as $v) {
$select[] = "(select * from $v)";
}
$sql = join(' UNION ', $select);
$res = mysql_query……
这样不好的,还是用php处理吧