请帮我解决我遇到的这个问题。我在 'where 子句' 中得到 '未知列 'the_mother_church_id' 。 我已经多次检查数据库中的列名的名称,并且我确定名称是相同的。
请问问题出在哪里。
谢谢
<?php
$past = mysql_query("SELECT * FROM the_mother_church WHERE the_mother_church_id = '1'") or die(mysql_error());
?>
创建表
CREATE TABLE IF NOT EXISTS `the_mother_church` (
` the_mother_church_id` int(255) NOT NULL,
`the_mother_church_head` varchar(255) NOT NULL,
` the_mother_church_content` varchar(3000) NOT NULL,
` the_mother_church_tags` varchar(255) NOT NULL,
` the_mother_church_created` datetime NOT NULL,
` the_mother_church_image` blob NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
最佳答案
(升级到答案)
您的 CREATE TABLE
语句显示该列的命名方式在起始引号和字段名称之间有一个空格:` the_mother_church_id`
。要么:
在查询中使用带有空格的列名称:
SELECT * FROM the_mother_church WHERE ` the_mother_church_id` = '1'
重命名列:
ALTER TABLE `the_mother_church` CHANGE ` the_mother_church_id` `the_mother_church_id` int(255) NOT NULL, CHANGE ` the_mother_church_content` `the_mother_church_content` varchar(3000) NOT NULL, CHANGE ` the_mother_church_tags` `the_mother_church_tags` varchar(255) NOT NULL, CHANGE ` the_mother_church_created` `the_mother_church_created` datetime NOT NULL, CHANGE ` the_mother_church_image` `the_mother_church_image` blob NOT NULL;
关于php - 数据库中的未知列问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10410088/