MYSQL中的条件结果查询

MYSQL中的条件结果查询

本文介绍了如何限制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)

这篇关于如何限制PHP/MYSQL中的条件结果查询?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 01:55