Hi,
I’m currently trying to learn how to do sql queries in different ways with yii.
And so with this approach i am trying to retrieve Title from my tbl_album and Name
from genre table called tbl_genre. So i will have to join them on GenreId which is located in both tables.
Shouldnt this work?
Query:
$content2=Yii::app()->db->createCommand()
->select('Title, tbl_genre.Name')
->from('tbl_album a')
->join('tbl_genre g', 'a.GenreId=g.GenreId')
->where('AlbumId=386')
->queryRow();
Error:
CDbException
CDbCommand failed to execute the SQL statement: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'tbl_genre.Name' in 'field list'. The SQL statement executed was: SELECT `Title`, `tbl_genre`.`Name`
FROM `tbl_album` `a`
JOIN `tbl_genre` `g` ON a.GenreId=g.GenreId
WHERE AlbumId=386