如何限制PHP/MYSQL中的条件结果查询?

问题描述:

我需要限制条件为WHERE的查询的前六个结果.

I need to limit the first six results from a query with a condition WHERE.

我想做这样的事情:

mysql_query("CREATE VIEW [test] AS SELECT * FROM table WHERE status=1");

$sel = "SELECT * FROM [test] LIMIT 0,6";

$result = mysql_query($sel);

while($r=mysql_fetch_array($result)){ 
    echo "".$r['id']."<br>";
}

我该怎么办?谢谢!

$query = "SELECT * FROM `table` WHERE this = 'that' ";
$limit = "ORDER BY index LIMIT 6 ";
$result = mysql_query($query.$limit);

您需要限制订购的条件选择. (您可能不必订购此商品)

You need to limit your ordered conditional selection. (You probably don't have to order this)