Column Not Found In Cdbcriteria Join


So I thought I would have cracked my problem when reading this following post. I’ve compared this query to mine below … but I’m still getting Unknown column ‘EntrySubject.subject_id’. What am I doing wring folks?

		$subjectEntries = new CDbCriteria();

		$subjectEntries->alias = 'EntrySubject';

		$subjectEntries->join = 'INNER JOIN Subject ON = EntrySubject.subject_id';

		$subjectEntries->select = ', EntrySubject.subject_id';

		$subjectEntries->condition = ''.$id;


$subjectEntries->join = 'INNER JOIN Subject'


Seems like you’re joining Subject with Subject, is that by purpose?

definitely not. here’s my original SQL … am I getting myself confused?

SELECT, entry_subject.subject_id FROM entry_subject INNER JOIN subject ON entry_subject.subject_id = WHERE = 71

I suppose you should use either EntrySubject::model()->findAll or $subjectEntries->join = ‘INNER JOIN entry_subject’, depending on what you really need.