in my sql how does my case statement is wrong ```...
# sql
g
in my sql how does my case statement is wrong
Copy code
delete from dbo.errors  
	where 
		CASE 
			WHEN @typeofcolumn='e'  THEN 'errorid' = @bugid ELSE NULL END
		CASE 
			WHEN @typeofcolumn='b'  THEN 'bugid' = @bugid ELSE NULL END
	return;
trying to use in the procedure
m
is there an error message or it just doesn't delete?
c
I've never tried to use a CASE statement inside the WHERE clause before, so I'm not sure if that's valid SQL or not.
m
What about
Where (@typecolumn = 'e' AND errorID = @bugID) OR (@typeColumn = 'b' AND bugID = @bugID)
b
I don't think you want the WHERE clause. https://www.w3schools.com/sql/sql_case.asp
g
CASE statement could be used in WHERE clause, but the syntax above was wrong. What is the logic you would implement?
c
I'd probably do something like this
Copy code
CASE 
   WHEN @typeofcolummn in ('e','b') THEN 'error' = @bugid
ELSE NULL
END;