dqhnp44220 2013-04-12 08:05
浏览 395
已采纳

简单的MySQL SELECT失败,错误1054未知列

I did research on this question and nothing I've read in the MySQL manual, in MySQL bug reports, in Stack Overflow, or in other forums has helped so far.

I have a simple mysql select query:

SELECT * FROM `Toyota` WHERE `Toyota`.`CollisionEstimatingID` = '22028589';

This query fails with mysql error code 1054

Unknown column Toyota.CollisionEstimatingID in the WHERE clause

This column DOES exist, I've checked the spelling of the database, table and column at least 30 times now. I even deleted my database and reimported. I have tried it with the backticks and without backticks, with alias' and without alias' I've tried it with explicitly named table.column syntax, and without the explicit syntax, I've tried mixing and matching all the stuff I've mentioned (backticks on the table, but not the column, on the column but not the table name), and nothing seems to work. It fails when I execute it from the mysql CLI on Ubuntu 12.04, it fails from my PHP 5.3 code, and it fails inside of phpMyAdmin. I am ready to flip a table.

When I try this though:

SELECT * FROM `Toyota`;

This works without any problems? Good god, MySQL is such a tease...

Here is the table setup as derived from show create database Toyota;

CREATE TABLE `Toyota` (
  `CollisionEstimatingID` varchar(255) DEFAULT NULL,
  `OE_part_number` varchar(255) DEFAULT NULL,
  `Price` varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1

An interesting note -- I wonder if it could be character encoding problems? I did get it to work ONCE in phpMyAdmin by using the show create table Toyota and deleting everything but the "CollisionEstimatingID" and used that to form the SELECT statement. But when I tried cutting and pasting, no dice.

I tried recreating the database and tables using the utf8 character set to see if that would help, but it didn't help. I tried copying to text out of the phpMyAdmin window and into my source code -- that produced some funky characters at the beginning of the column name -- kinda like this: >>?CollisionEstimatingID only it was an 'i' with an umlaut + a double right chevron and an upside down question mark.

I'm stumped. Anyone want to test their programming mettle and help a brother out?

  • 写回答

2条回答 默认 最新

  • duanjia8215 2013-04-12 08:50
    关注

    Like ""?

    This is the UTF-8 BOM (en.wikipedia.org/wiki/Byte_order_mark).

    You probably need to clean the input files first.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 我的数据无法存进链表里
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端