jeudi 26 février 2015

Stored procedure to check if username exists


I'm trying to write a stored procedure


So far I have this, but it always returns 1



CREATE DEFINER=`root`@`localhost` PROCEDURE `USER_EXISTS`(IN `USERNAME` VARCHAR(64) CHARSET utf8mb4)
SELECT CASE WHEN MAX(user_id) IS NULL THEN '0' ELSE '1' END User_exists
FROM `dbname`.`tablename`
WHERE `username` = USERNAME


The goal is to perform this via AJAX so the user can see whether registration is likely to succeed before submitting their registration form





Aucun commentaire:

Enregistrer un commentaire