我有类别1,2,3,4,5,6,7
如何显示来自表格'新闻'的所有结果没有类别3 ..?
TNX。
`id` int(20) NOT NULL AUTO_INCREMENT,
`title` varchar(256) NOT NULL,
`content` longtext NOT NULL,
`category` int(20) NOT NULL,
答案 0 :(得分:1)
非常简单,只需使用!= 3
。
SELECT * FROM news WHERE category != 3
答案 1 :(得分:0)
做类别的条件!=' 3'在查询中
您可以使用$cat_id
存储从结果中排除的任何类别。
$cat_id = 3;
$sql = "SELECT * FROM news WHERE category!='$cat_id'";
$qry = mysqli_query($con, $sql);
if (mysqli_num_rows($qry) > 0)
{
while ($res = mysqli_fetch_assoc($qry))
{
// Do the action
}
}