Home > Database > Mysql Tutorial > Why Does My SQL Query Return 'Column Does Not Exist' Even Though the Column Exists?

Why Does My SQL Query Return 'Column Does Not Exist' Even Though the Column Exists?

Barbara Streisand
Release: 2025-01-13 07:00:42
Original
867 people have browsed it

Why Does My SQL Query Return

SQL statement error: "Column does not exist"

In the provided SQL statement, the error message indicates that the FK_Numbers_id column does not exist in the database table. However, upon inspecting the table structure, it is clear that the FK_Numbers_id column does exist.

The problem stems from the case sensitivity of column names with double quotes. The table appears to be created with quoted column names, which makes them case sensitive. In this case, the FK_Numbers_id column name must be enclosed in double quotes:

<code class="language-sql">select sim.id as idsim,
       num.id as idnum
from main_sim sim
   left join main_number num on ("FK_Numbers_id" = num.id);</code>
Copy after login

By correctly enclosing the column name in double quotes, the SQL statement now accurately references the target column.

The above is the detailed content of Why Does My SQL Query Return 'Column Does Not Exist' Even Though the Column Exists?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template