简体   繁体   中英

mysql join multiple tables with same column name |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 .

您可以选择声明table.fieldname,并在查询“ table.fieldname AS newname”中编写...这是从不同表中检索相同列名的方式。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM