How to create a function in MySQL that will return a random bool So far I've got this:

CREATE FUNCTION IS_ROLEMEMBER (@Rolename VARCHAR(255), @Username VARCHAR(255)) 
RETURNS BINARY AS 
RETURN ( 
 SELECT (FLOOR(RAND() * 10) % 2) AS BINARY
);


But that gives me "wrong syntax by 'RETURN ( SELECT (FLOOR(RAND() * 10) % 2) AS BINARY)'"

ignore the paramters and function name, I want this for testing
It looks like you had a couple of errors. Try

CREATE FUNCTION IS_ROLEMEMBER (Rolename VARCHAR(255), Username VARCHAR(255)) 
RETURNS BINARY 
READS SQL DATA
RETURN 
( 
    SELECT (FLOOR(RAND() * 10) % 2)
);


The main errors I saw were:

@Rolename and @Username - no need to use @

RETURNS BINARY AS - no need for AS

I included the READS SQL DATA line as this caused an error on my side otherwise. I believe this is related to replication, so depending on your set up you may not need it.