2012-05-02 6 views
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 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; 
+2

당신이 우리에게 CREATE TABLE 문을 표시 할 수 있습니다 :

SELECT * FROM the_mother_church WHERE ' the_mother_church_id' = '1' 
  • 가 열 이름 바꾸기? NOT은'the_mother_church' ('the_mother_church_id'의 INT (255 있으면 – LeonardChallis

  • +0

    가 NULL NOT) TABLE 만들기 'the_mother_church_head' VARCHAR (255) NOT NULL, 'the_mother_church_content' VARCHAR (3000) NULL NOT, 'the_mother_church_tags' VARCHAR (255) NOT NULL, 'the_mother_church_created' datetime NOT NULL, 'the_mother_church_image' blob이 NULL이 아님 ) ENGINE = InnoDB DEFAULT CHARSET = latin1; –

    +0

    @ user1365922 : 질문을 수정할 수 있습니까 (태그 바로 아래에있는 '수정'링크를 참조하십시오). 그러면 읽을 수 있도록 대신 그 곳에 붙여 넣을 수 있습니까? – eggyal

    답변

    2

    귀하의 CREATE TABLE 문은 열이 개방 견적 및 필드 이름 사이에 공백으로 선정되었습니다 보여줍니다 (답변-업그레이드) : ` 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; 
      
    1

    확인을 만듭니다. 난 당신이 backticks에 필드 이름을 래핑하는 것이 좋습니다.

    +2

    OP가 이미 여러 번 확인했는데'the_mother_church_id'는 확실히 ** 예약어가 아님을 감안할 때 (http://dev.mysql.com/doc/refman/5.5/en/reserved- words.html) MySQL에서, 나는이 대답이 특히 도움이된다고 확신하지는 않는다 ... – eggyal

    +0

    필드가 테이블에 존재하면,이 필드가 사용하는 SQL- 쿼리에서 오류가 발생한다. –

    +0

    그가 여러 번 확인했을 때 그는 틀렸고 필드를 다시 확인해야했습니다. 유효한 대답. – LeonardChallis

    0

    테이블 구조의 필드 이름 앞에 공백이 있습니다.
    필드 이름에서 공백을 제거하고 테이블을 다시 만드는 것이 좋습니다.

    ` the_mother_church_id` 
    ^ an excessive space 
    
    +0

    감사합니다. –