user3571514
user3571514

Reputation: 91

Zend join three columns

I have three columns album, album_images, image_name. What I'm trying to do is combine the columns.

I have a problem following code:

$select = $db->select()
->from(array('a' => 'album_images'), array('album_id', 'image_names_id'))
->join(array('b' => 'image_names'), 'a.image_names_id = b.id', array())
->join(array('c' => 'album'), 'c.album = a.album_id', array('id'))
->where('c.id = ?', $id);

When I do this I get the following error:

Message: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'c.album' in 'on clause'

What did I do wrong?

Upvotes: 0

Views: 74

Answers (1)

Daniel Gadawski
Daniel Gadawski

Reputation: 1923

Just like the message says - there's no "album" column in "album" table. Maybe it should be like:

->join(array('c' => 'album'), 'c.id = a.album_id', array('id'))

Upvotes: 2

Related Questions