dongrong9053 2016-01-04 13:43
浏览 94

MySQLi!=没有处理多个AND / OR子句

So I have two rows in my Database - user_one and user_two, these rows are occupied by User ID's as numbers for a messaging system, I have also included a support ticket system within the same message feature but am having a few issues with this code snippet...

$sqlc="SELECT * FROM ap_conversations WHERE user_one = '$user_id' AND user_two != '999' OR user_two = '$user_id' AND user_one != '999' OR user_one = '$user_id' AND user_two != '999d' OR user_two = '$user_id' AND user_one != '999d'";

As you'll notice, the support tickets ID is 999, and when it was kept to just checking that neither ID's were 999 this code worked perfectly. Although I also need it to check that neither user_one or user_two has ID's of 999 or 999d. This current code returns 1, when I know for a fact it should return 0 so I know something is defiantly going wrong and I think I may have it set up incorrectly. I have attempted to set it up like this in many different formats:

$sqlc="SELECT * FROM ap_conversations WHERE user_one = '$user_id' AND (user_two != '999' OR user_two != '999d') OR user_two = '$user_id' AND (user_one != '999' OR user_one != '999d')";

But still get the same results? Can anybody tell me what I am doing wrong here or how I can make this code perform better?

  • 写回答

3条回答 默认 最新


      相关推荐 更多相似问题


      • ¥15 结构体数组文件读取问题
      • ¥15 写c++代码,第7题说一下使用的计算方法
      • ¥15 postman接口自动化测试报告实践总结
      • ¥15 有关c++的问题,利用相关知识
      • ¥15 求香农编码和解码的matlab代码
      • ¥20 ROS中的TEB局部规划问题
      • ¥20 关于#matlab#的问题:要求测出上面图片中所有同心圆的半径
      • ¥20 epanet软件运行问题
      • ¥15 Python 文件读取
      • ¥60 dpabi进行Alff计算时脑池有干扰信号