Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use boolean on mysql login procedure

Tags:

php

mysql

Procedure parameters

BEGIN

    IF EXISTS (SELECT *
              FROM customer
              WHERE usern = p_user AND password = p_pass)

                SET p_output = 1;
    ELSE
                SET p_output = 0;

END;

MySQL gives me the error 1064, it's in the output. How i can do that set correctly? I have to give values ​​to the p_output parameter? You can see how i did it in the image.

Thank you!


1 Answers

You are missing both the THEN and the END IF for your IF clause. Try this:

BEGIN    
    IF EXISTS (SELECT *
              FROM customer
              WHERE usern = p_user AND password = p_pass) THEN
                SET p_output = 1;
    ELSE
                SET p_output = 0;
    END IF;    
END;
like image 188
Nick Avatar answered Jan 31 '26 23:01

Nick



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!