Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 240735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:41:29+00:00 2026-05-11T20:41:29+00:00

Ok, building off of the last question I asked , How does Mysql handle

  • 0

Ok, building off of the last question I asked, How does Mysql handle the where statment in the following code:

DELIMITER ;//
DROP PROCEDURE IF EXISTS `test`;//
CREATE PROCEDURE `test`
(
  id INT
)
BEGIN
  SELECT *
    FROM some_table
   WHERE id = id;
END;//

What does MySQL do in this case? Does it treat the where clause as

some_table.id = id

or does it treat it like

some_table.id = some_table.id 

Right now I am doing something like

WHERE id = @id

because I didn’t know that there were session variables in MySQL and it didn’t complain and I thought that it was an explicit way of saying “where this column equals this variable”.

Some might say “duh.. of course it treats it as column = variable” but I could easily have said where “variable = column.” So how does it handle this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:41:29+00:00Added an answer on May 11, 2026 at 8:41 pm

    MySQL’s variable naming schema is a bit weird, when having the first look into it. Generally MySQL differentiates between three types of variables:

    • system variables (global or session scoped): @@varname
    • user defined variables (they are session scoped): @varname
    • local variables in stored programs: varname

    So naming conflicts, such as those you mentioned above, only arise within stored programs. Therefore you first should try to avoid these naming conflicts by assigning unambiguous parameter names, e.g. by prefxing the parameters with p such as pId. If MySQL encounters an ambiguity it will interpret the reference as the name of a variable (see here):

    […] Local variable names should not
    be the same as column names. If an SQL
    statement, such as a SELECT ... INTO
    statement, contains a reference to a
    column and a declared local variable
    with the same name, MySQL currently
    interprets the reference as the name
    of a variable.
    […]

    The wording currently somehow gives the impression that this behaviour could change in future versions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building off of a question I had asked and resolved earlier: front end
So, building off a question about string matching ( this thread ), I am
building on my last question jQuery getting values from multiple selects together I have
I was building a bit of code that would trim off any non-digit entries
Building off Does Perl have an enumeration type? , how can I perform dynamic
I am new to VBA and building off of someone else's code, who was
I'm building off this question and creating a simple ImageButton class that represents a
Possible Duplicate: Learning C++: polymorphism and slicing This is building off a question I
I think I have two different questions here, I'm building off this question .
Building off this question, How to implement an achievement system in RoR would I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.