【发布时间】:2017-05-18 16:11:53
【问题描述】:
我有 2 个不同的表,具有相同的列名 tbl_specialty 和 tbl_student。我做了一个 JOIN 语句来加入 2 个表,现在我想输出表 1 的列名和表 2 的列名,我该如何实现呢?我只从一列复制。 请帮忙。
我的观点
<?php
foreach ($delegates->result() as $row )
{?>
<tr>
<td><a href=""> <?php echo $row->name; ?></a></td>
<td class="center"><?php echo $row->job; ?></td>
<td class="center"><?php echo $row->name; ?></td>
<td class="center"><?php echo $row->workplace;?></td>
<td class="center"><?php echo $row->country_name; ?></td>
</tr>
我的模型
public function delegates_per_course() {
$this>db>select('tbl_student.name,tbl_student.workplace,tbl_student.job,tbl_student.dob,tbl_student.email,tbl_student.mobile,tbl_country.country_name,tbl_specialty.name,tbl_country.country_id,tbl_country.country_name');
$this->db->from('tbl_student');
$this->db->join('tbl_country','tbl_student.country_id=tbl_country.country_id');
$this->db->join('tbl_specialty','tbl_student.specialty_id=tbl_specialty.id');
$this->db->order_by("tbl_country.country_name");
$query = $this->db->get();
return $query;
}
【问题讨论】:
标签: mysql codeigniter codeigniter-2 codeigniter-3