SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE Products (ID Int, Status CHAR(1)); INSERT INTO Products VALUES (1, 'C'), (2, 'C'), (3, 'E'), (4, 'R'), (5,'I'), (6,'R'), (7,'E'), (8,'C'), (9,'C'), (10,'R'); DECLARE @Status VARCHAR(50) SET @Status='D' SELECT * FROM Products P WHERE P.Status = @Status or @Status='ALL'; --@Status='E' and P.Status = 'E' -- or @Status='C' and P.Status = 'C' -- or @Status='deleted' and P.Status IN (4,5,8,10); -- or P.Status IN (1,2);
Stuck with a problem? Got Error? Ask ChatGPT!
Copy Clear