[英]How to limit a conditioned result query in PHP/MYSQL?
I need to limit the first six results from a query with a condition WHERE. 我需要限制条件为WHERE的查询的前六个结果。
I would like to do something like that: 我想做这样的事情:
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>";
}
How can I do it? 我该怎么做? Thanks!
谢谢!
$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)
(您可能不必订购此产品)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.