I created a procedure that has two arguments passing in:
CREATE PROCEDURE seleb (bal varchar(2), p INT)
The variable bal has value of either '<', '<=', or '='. Inside of the procedure, there is a query:
SELECT title
FROM book_list
WHERE price bal p;
This brought me an error at 'WHERE price bal p' because I want to save the effect of writing three if statement:
IF bal=='<'
....
WHERE price < p;
ELSE IF bal=='<='
....
WHERE price <= p;
ELSE IF bal=='='
....
WHERE price = p;
But I don't want to write three if statement. Is there any way that I can prevent from doing that? I want to write it in a single query.
Thanks