I don't have the answer you seek, but maybe this can help get you on your way. If you:
echo $select->__toString(); You will see: SELECT `s`.`sid`, `s`.`name`, `s`.`status`, `r`.`rid`, `r`.`rdate`, `sc`.*, `c`.`name` FROM `student` AS `s` INNER JOIN `registration` AS `r` ON s.sid = r.sid INNER JOIN `student_course_interests` AS `sc` ON s.sid = sc.sid INNER JOIN `course` AS `c` ON c.cid = sc.cid the SQL that is being generated for you. You can place this after any $select statement to see step by step generated code. You also have the option of passing your select statement like this: $select = $db->query('select s.sid, s.name, r.rid, r.rdate, c.name, s.status from student as s, registration as r, student_course_interests as sc, course as c where s.sid=r.sid and s.sid=sc.sid and c.cid=sc.cid'); $result = $select->fetchAll(); That's the best I can offer for now. Others surely know a lot more then I. Jim Sudheer Satyanarayana wrote: > > Hello experts, > > I am trying to implement a MySQL query with Zend_DB. The query is: > > select s.sid, s.name, r.rid, r.rdate, c.name, s.status from student as > s, registration as r, student_course_interests as sc, course as c where > s.sid=r.sid and s.sid=sc.sid and c.cid=sc.cid > > When I execute this query in the MySQL client, I get the desired result. > I tried various types of queries with ZF. I don't understand why Zend_DB > changes the column positions. The below query doesn't seem to select > s.name at all. > > [code] > > $select = $db->select(); > $select->from(array('s' => 'student'), > array('s.sid','s.name','s.status')); > $select->join(array('r' => 'registration'), > 's.sid = r.sid', > array('r.rid','r.rdate')); > $select->join(array('sc' => 'student_course_interests'), > 's.sid = sc.sid'); > $select->join(array('c' => 'course'), > 'c.cid = sc.cid', > array('c.name')); > $result = $db->fetchAll($select); > > [/code] > > How can I fix this? > > Any help is greatly appreciated. > > Regards, > Sudheer > > -- View this message in context: http://www.nabble.com/Help-to-implement-a-join-query-in-Zend_Db-tp16506242p16511355.html Sent from the Zend Framework mailing list archive at Nabble.com.