MySQL Add/Grant user if it does not exist
What you need is Dynamic SQL

SET @sql_found='SELECT 1 INTO @x';
SET @sql_fresh='GRANT ALL ON *.* TO randomuser@''%'' IDENTIFIED BY ''randompassword''';
SELECT COUNT(1) INTO @found_count FROM mysql.user WHERE user='randomuser' AND host='%';
SET @sql=IF(@found_count=1,@sql_found,@sql_fresh);
PREPARE s FROM @sql;
EXECUTE s;
DEALLOCATE PREPARE s;


If @found_count is 1, then SELECT 1 INTO @x; will execute. (this query does nothing)

Otherwise, GRANT ALL ON *.* TO randomuser@'%' IDENTIFIED BY 'randompassword';

Give it a Try !!!