drs7798 2016-06-06 06:53
浏览 27

mysql连接具有相同列名的多个表| Codeigniter |

I'm making an admin page and I want to join multiple tables. That works out for so far.

But now I want to join an other table but it haves the same column name as I use in the other join querys.

is there a way how i can get it working with out changing the column his name

this is my code right now:

$this->codeignitercrud->table ( 'user_to_designment' );
$this->codeignitercrud->tableAlias ( 'Users to designment' ); 
$this->codeignitercrud->join ( 'right', 'users', 'user_to_designment.user_id = users.user_id');
$this->codeignitercrud->join ( 'right', 'user_profiles', 'users.username = user_profiles.email');
$this->codeignitercrud->join ( 'right', 'designments', 'user_to_designment.designment_id = designments.designment_id');
// This one makes a problem now -- >$this->codeignitercrud->join ( 'right', 'inspiration', 'users.user_id = inspiration.user_id');

$this->codeignitercrud->addNoCol ( true );


$this->codeignitercrud->cols ( 'designment_id');
$this->codeignitercrud->cols ( 'designments.title');
$this->codeignitercrud->cols ( 'users.username');
$this->codeignitercrud->cols ( 'user_profiles.first_name');
$this->codeignitercrud->cols ( 'user_profiles.last_name');

i have to get all the fields to be shown of the column.

Thanks in advance .

  • 写回答

1条回答 默认 最新

  • dongyan5706 2016-06-06 07:12
    关注

    You have option to declare table.fieldname, and to write in query "table.fieldname AS newname"... That is the way to retrieve same column names as different from different tables.

    评论

报告相同问题?