Need help wit this problem:
Each record for a PhysicalSource has a Status number.
I need to do a SELECT statement to find out if there is a Status = 2 in any of the records.
If Status = 2 then I need to return all rows for this PhysicalSource else if Status != 2 then I need to exit the query (don’t return anything).
The statement is as follows:
SELECT SourceID, OriginalTime, State FROM sources WHERE SourceID = ? AND PhysicalSource = ? AND IF(Status = 2, 0, 1) Order by SourceID ASC
As I found out the “IF(Status = 2, 0, 1)” evaluates every row and returns all others with Status !=2.
The options are limited, I inherited a GUI (can’t modify it) that must be use and only accepts one query at a time using MySQL version 4.1.11.
Could someone help with a way to have this evaluate multiple rows, as one, and if in any of them Status = 2 then exit the query?
Thanks
Each record for a PhysicalSource has a Status number.
I need to do a SELECT statement to find out if there is a Status = 2 in any of the records.
If Status = 2 then I need to return all rows for this PhysicalSource else if Status != 2 then I need to exit the query (don’t return anything).
The statement is as follows:
SELECT SourceID, OriginalTime, State FROM sources WHERE SourceID = ? AND PhysicalSource = ? AND IF(Status = 2, 0, 1) Order by SourceID ASC
As I found out the “IF(Status = 2, 0, 1)” evaluates every row and returns all others with Status !=2.
The options are limited, I inherited a GUI (can’t modify it) that must be use and only accepts one query at a time using MySQL version 4.1.11.
Could someone help with a way to have this evaluate multiple rows, as one, and if in any of them Status = 2 then exit the query?
Thanks