Jump to content

VERY simple stored function returning different result?


neller

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.