neller Posted December 10, 2009 Share Posted December 10, 2009 Ok I have a pretty basic stored function but it returns a different result to the query inside it? let me show you a quick example so it makes more sense, here is the query and the result it returns... SELECT username FROM users WHERE user_id = 1; (returns "Player 1") however, when I use that exact same query within a stored function it returns a totaly different result CREATE DEFINER=`root`@`localhost` FUNCTION `get_Username`() RETURNS varchar(128) CHARSET latin1 BEGIN RETURN (SELECT username FROM users WHERE user_id = 1); END (returns "Player 2"); The table itself is just a basic one containing usernames with user_id as a Primary key. any help will be much apprieated Quote Link to comment https://forums.phpfreaks.com/topic/184586-very-simple-stored-function-returning-different-result/ Share on other sites More sharing options...
neller Posted December 10, 2009 Author Share Posted December 10, 2009 nevermind fixed it.... I just put ` around all the table names and it seems to have fixed the problem, I do usually use these in my queries anyways but left them out the function for some reason. Quote Link to comment https://forums.phpfreaks.com/topic/184586-very-simple-stored-function-returning-different-result/#findComment-974460 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.