我正在使用Kohana。我正在尝试选择一个列some name
但是它给出了错误 -
Table 'users AS U' doesn't exist
如何制作这个别名?
$result = DB::select( 'users.firstname',
'users.lastname',
'U.firstname AS alt_firstname',
'U.lastname AS alt_lastname'
)
->from('mytable')
->join('table2', 'INNER')
->on('mytable.id', '=', DB::expr('table2.id'))
->join('users', 'INNER')
->on('users.id', '=', DB::expr('mytable.id'))
->join('users AS U', 'INNER')
->on('U.id', '=', DB::expr('table2.id'))
->execute();
return $result;
答案 0 :(得分:1)
$ query = DB :: select(array('username','u'),array('password','p')) - > from('users');
https://kohanaframework.org/3.3/guide/database/query/builder#select-as-column-aliases