结合两个而且& sql语句

时间:2010-12-02 13:35:05

标签: php mysql

如果可能,我需要将两个查询组合在一起,或者让它们一个接一个地处理。我假设$Record_Count = $Record_Count + 1;不需要在那里两次,因为那只是为了分页脚本。 (提前谢谢)

$results = mysql_query("SELECT * load_test WHERE language = '".$lang."' ORDER BY Id DESC, creationdate DESC LIMIT $start, 5");
while ($data = mysql_fetch_array($results)) {
    $Record_Count = $Record_Count + 1;

$rec_res = mysql_query("SELECT * FROM names WHERE com_id = '".$data[Id]."'");
while ($recdata = mysql_fetch_array($rec_res)) {
    $Record_Count = $Record_Count + 1; 

1 个答案:

答案 0 :(得分:1)

如果$Record_Count只计算返回的行数,您可以随时使用mysql_num_rows()

$results = mysql_query("SELECT * FROM load_test WHERE language = '".$lang."' ORDER BY Id DESC, creationdate DESC LIMIT $start, 5");
$rec_res = mysql_query("SELECT * FROM names WHERE com_id = '".$data[Id]."'");

$Record_Count += mysql_num_rows($result) + mysql_num_rows($rec_res);