无法使用 where 条件
Failed to use where condition
我已经开发了一个应用程序,现在需要在我的查询中使用 where 条件来整理从 75000 到 150000 的汽车范围..但它没有 return 任何东西..任何人都可以帮忙我来解决这个问题
<?php
if(isset($_GET['id']))
{
mysql_query($qry);
}
$result = mysql_query("SELECT * FROM cars where (price<75000 and price>150000)");
echo "<table border='1'>
<tr>
<th>Id</th>
<th>color</th>
<th>cond</th>
<th>make</th>
<th>price</th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";?>
<td width=5%>
<?php echo $row['id']; ?>
</td>
<td width=10%>
<?php echo $row['color']; ?>
</td>
<td width=10%>
<?php echo $row['cond']; ?>
</td>
<td width=10%>
<?php echo $row['make']; ?>
</td>
<td width=10%>
<?php echo $row['price']; ?>
</td>
<?php
echo "</tr>";
}
你的条件有误
SELECT * FROM cars
where price > 75000 and price < 150000
^-----------------^--------------------here
您也可以使用
SELECT * FROM cars
where price between 75000 and 150000
但这包括 75000
和 150000
据我所知,我认为您的 WHERE 子句是错误的。
WHERE (price<75000 and price>150000)
,
我认为应该是:
WHERE (price > 75000 AND price < 150000)
,你也可以用
BETWEEN 子句。
我已经开发了一个应用程序,现在需要在我的查询中使用 where 条件来整理从 75000 到 150000 的汽车范围..但它没有 return 任何东西..任何人都可以帮忙我来解决这个问题
<?php
if(isset($_GET['id']))
{
mysql_query($qry);
}
$result = mysql_query("SELECT * FROM cars where (price<75000 and price>150000)");
echo "<table border='1'>
<tr>
<th>Id</th>
<th>color</th>
<th>cond</th>
<th>make</th>
<th>price</th>
</tr>";
while($row = mysql_fetch_array($result)) {
echo "<tr>";?>
<td width=5%>
<?php echo $row['id']; ?>
</td>
<td width=10%>
<?php echo $row['color']; ?>
</td>
<td width=10%>
<?php echo $row['cond']; ?>
</td>
<td width=10%>
<?php echo $row['make']; ?>
</td>
<td width=10%>
<?php echo $row['price']; ?>
</td>
<?php
echo "</tr>";
}
你的条件有误
SELECT * FROM cars
where price > 75000 and price < 150000
^-----------------^--------------------here
您也可以使用
SELECT * FROM cars
where price between 75000 and 150000
但这包括 75000
和 150000
据我所知,我认为您的 WHERE 子句是错误的。
WHERE (price<75000 and price>150000)
,
我认为应该是:
WHERE (price > 75000 AND price < 150000)
,你也可以用
BETWEEN 子句。