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?