我的查询看起来像

SELECT а.*, m.username, m.picture, m.picture_active
FROM questions_answer AS а
INNER JOIN members AS m ON а.poster_id=m.member_id
INNER JOIN questions AS q ON q.question_id=a.question_id
ORDER BY a.postdate DESC


我收到错误消息:

Unknown column 'a.question_id' in 'on clause'


我不知道怎么了,请帮我解决这个问题。

questions

CREATE TABLE IF NOT EXISTS `questions` (
  `question_id` int(9) unsigned NOT NULL AUTO_INCREMENT,
  `member_id` int(9) unsigned NOT NULL DEFAULT '0',
  `question` text NOT NULL,
  `postdate` int(10) unsigned NOT NULL DEFAULT '0',
  `active` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`question_id`),
  KEY `member_id` (`member_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;


并且questions_answer

CREATE TABLE IF NOT EXISTS `questions_answer` (
  `answer_id` bigint(12) unsigned NOT NULL AUTO_INCREMENT,
  `question_id` int(9) unsigned NOT NULL,
  `poster_id` int(9) unsigned NOT NULL,
  `body` text NOT NULL,
  `postdate` int(9) unsigned NOT NULL,
  PRIMARY KEY (`answer_id`),
  KEY `question_id` (`question_id`),
  KEY `poster_id` (`poster_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;

最佳答案

您的表questions_answer可能没有列question_id

关于php - 'on子句'中的MySQL未知列:(,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18814468/

10-10 03:23