Error: Column 'mary' Does Not Exist
In the provided SQL query, Gabriel encounters an error stating that the column "Mary" does not exist. However, their intention is to use "Mary" as a value, not as a column name.
The error occurs because Gabriel used smart quotes (“ ”) to enclose the string literal 'Mary'. Smart quotes are visually distinct from plain single quotes (' ').
Solution:
To resolve this issue, Gabriel should use plain single quotes to delimit the string literal:
SELECT telephone.telephonenumber as tel FROM person, telephone WHERE person.idperson = telephone.idperson AND person.personname = 'Mary';
Plain single quotes are the standard delimiter for string literals in SQL. Smart quotes may interfere with the query execution, leading to the error message that "Mary" does not exist.
The above is the detailed content of Why Does My SQL Query Show 'Column 'Mary' Does Not Exist'?. For more information, please follow other related articles on the PHP Chinese website!