0

I'm testing user defined variable directly in PHPMyAdmin's console.

I've observed that if I create:

SET @myVariable = 14;

I execute it, and then try to use it in another query during the same session:

SELECT * FROM tblstaff WHERE staffid = @myVariable;

I execute it too but then I receive an empty table.

Now if I execute the exact same queries but in one go, the table returned contains the right info I need.

This does not look like a normal behavior to me. I'm still in the same session so the user defined variable should be recognized.

Can someone tell me if this behavior is normal in PHPMyAdmin? When I look at Youtube videos in other environments than PHPMyAdmin it seems like people don't have problems executing queries one after another.

Thank you :)

2
  • 1
    For each interaction with Database server a new connection will be established, so the content of previously defined session variables will be NULL. You can check this with SELECT connection_id() Commented Jan 2, 2024 at 15:18
  • Indeed, I just tested it. That explains the behavior observed. Thanks. Commented Jan 2, 2024 at 16:16

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.