<?php
$sql=$empire->query("select * from table1 order by id limit 20");$num = mysql_num_rows($sql);
echo "从表一取出:".$num."条数据";$two=20-$num;
if($num<21)
{ $sql1=$empire->query("select * from table2 order by id limit $two"); $num1 = mysql_num_rows($sql1);echo "从表二取出:".$num1."条数据";}?>
以上代码表示,先查询table1取20条数据,当取的数据不足20条时,用20-已取的数量,再通过table2取不足的信息条数。