I write a stored procedure as below but always result nothing/incorect.

DELIMITER //

DROP PROCEDURE IF EXISTS get_domain //

CREATE PROCEDURE get_domain (IN domin VARCHAR(64))
BEGIN
	SELECT * FROM domain_senders WHERE domain LIKE '%domin%';
END//

DELIMITER ;

The procedure itself is successfully created.After looking around with google i’ve found the solution.I need second variable to concat/stash %domin%

Here’s the store procedure, and it work like a charm :)

DELIMITER //

DROP PROCEDURE IF EXISTS get_domain //

CREATE PROCEDURE get_domain (IN domin VARCHAR(64))
BEGIN
	SET @vardomain := CONCAT('%',LOWER(TRIM(domin)),'%');
	SELECT * FROM domain_senders WHERE domain LIKE @vardomain;
END//

DELIMITER ;
Share