I am having unexpected results from MariaDB IF EXISTS... in a stored procedure. I created a minimal example to demonstrate the issue:
PROCEDURE testdb.testSearchResults(IN pParam1 INT, IN pParam2 CHAR(2))
BEGIN
IF EXISTS(SELECT COUNT(*) FROM test WHERE intval = pParam1 AND text = pParam2) THEN
SELECT 'Found' AS result;
ELSE
SELECT 'Not Found' AS result;
END IF;
END
No matter what the contents of the file "test" or the parameters I give to the call, this procedure always returns "Found".
Am I doing something wrong?
Thanks.