Jump to content

VERY simple stored function returning different result?


Recommended Posts

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.