Hello,
I want to make a conditional SQL. I have one table "users" and it has two columns (id, status)
I need to search for users IDs based on their status. For example.
Every 5 seconds I am querying from the database (by AJAX) as per the below description:
Let us say that I have the below results on my wall (on html):
id1: 1
status2: "A"
id2: 2
status2: "B"
I need to get IDs from table "users" but exclude the IDs from database if their statuses haven't changed on my wall.
So the algorithm should be:
Get all IDs from table "users" but exclude the IDs (1,2) from database (if and only if) their status = ("A", "B").
Simply, I need to retrieve all IDs including the IDs (1,2). But for the IDs (1,2): I need to retrieve them in case their corresponding statuses are NOT EQUAL ("A", "B") respectively.
But for IDs other than (1,2) like (3,4,5,...), I need to retrieve them without any condition.
I would greatly appreciate if the solution provides an excellent performance when the database records are huge and the check every 5 seconds.
Thanks in advance.
Cheers,