[英]How to use Multiple OR on WHERE Clause?
I am having a problem with my MYSQL statement 我的MYSQL语句有问题
Warning : mysqli_num_rows() expects parameter 1 to be mysqli_result, bool given in C:\\Users\\RBLara\\Documents\\My Projects\\focalnews\\index.php on line 188
警告:mysqli_num_rows()要求参数1为mysqli_result,bool在第188行的C:\\ Users \\ RBLara \\ Documents \\ My Projects \\ focalnews \\ index.php中给出
$sqltype = "SELECT * FROM focalnews_items ORDER BY datime ASC limit $last,20 WHERE (likes >= 5 OR love >= 5 OR informative >= 5)";
$resulttype = mysqli_query($conn, $sqltype);
if (mysqli_num_rows($resulttype) > 0) {
while($row = mysqli_fetch_assoc($resulttype))
{
$profile_pic = $row["profile_pic"];
$author = $row["author"];
$message = $row["message"];
$likes = $row["likes"];
$love = $row["love"];
$informative = $row["informative"];
$datime = $row["datime"];
$joined_date = $row["joined_date"];
}
}
?>
Any Idea please? 有什么想法吗?
ORDER BY and LIMIT should be goes at the end.
ORDER BY和LIMIT应该在最后。
You can use the multiple conditions in OR
as follows 您可以在
OR
使用多个条件,如下所示
WHERE likes >= 5 OR love >= 5 OR informative >= 5
Your query should be 你的查询应该是
$sqltype = "SELECT * FROM focalnews_items WHERE likes >= 5 OR love >= 5 OR informative >= 5 ORDER BY datime ASC limit $last,20";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.