0

私が抱えているこの問題について私を助けてください。'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

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;
4

3 に答える 3

2

回答へのアップグレード

ステートメントCREATE TABLEは、列が開始引用符とフィールド名の間にスペースを入れて名前が付けられたことを示しています` the_mother_church_id`。また:

  1. クエリでスペースを含む列名を使用します。

    SELECT * FROM the_mother_church WHERE ` the_mother_church_id` = '1'
    
  2. 列の名前を変更します。

    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;
    
于 2012-05-02T08:35:11.993 に答える
1

フィールドの名前をもう一度確認してください。また、フィールド名をバッククォートで囲むことをお勧めします。

于 2012-05-02T08:25:20.967 に答える
0

テーブル構造のフィールド名の前にスペースがあります。
フィールド名からスペースを削除して、テーブルを再作成することをお勧めします。

` the_mother_church_id`
 ^ an excessive space
于 2012-05-02T08:35:04.890 に答える