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.

    评论

报告相同问题?

悬赏问题

  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用
  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入