php - 将 2 个 WHERE 语句放在一起

标签 php mysql sql

我在将两个 where 语句放在一起时遇到问题

我当前的代码:

include 'config.php'; 

$result22 = mysql_query("SELECT * FROM messages WHERE to_user='".$_SESSION['username']."'     AND to_read_yet='yes' ");


$num_rows22 = mysql_num_rows($result22);


echo "$num_rows22 ";

出于某种原因,这不起作用。我没有得到任何结果我已经检查了数据库并且应该有结果

最佳答案

您应该阅读有关 sql 语法的内容。在你用 bool 运算符放置任何数字条件之后。使用 2 次 where 不正确

$result = mysql_query("SELECT * FROM messages WHERE to_user='".$_SESSION['username']."'     AND to_read_yet='"no"' ");

关于php - 将 2 个 WHERE 语句放在一起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7672600/

相关文章:

php - "Notice: Undefined variable"、 "Notice: Undefined index"、 "Warning: Undefined array key"和 "Notice: Undefined offset"使用 PHP

来自旧硬盘系统的 mysql datadir 无法启动

mysql - 在 MySQL SUM 时间戳差异中实现 IF

sql - 根据列值将数据划分到不同的表中是否合理?

mysql - 用于导出成员详细信息的 SQL Join

php - 检查字符串是否包含垃圾邮件单词

php - 需要在 URL 中进行身份验证的 NSURLConnection sendSynchronousRequest

php - 使用 mySQLi 保留字和函数 - 安全

mysql - 如何更改复合主键以添加附加列

php - mysql 在 foreach 循环中插入,cron 不工作