Home >Database >Mysql Tutorial >Why Does My SQL Query Show 'Column 'Mary' Does Not Exist'?

Why Does My SQL Query Show 'Column 'Mary' Does Not Exist'?

Linda Hamilton
Linda HamiltonOriginal
2024-12-29 10:11:13580browse

Why Does My SQL Query Show

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn