我有这个疑问:显示从内部名称与编号加入
select * from countrysegments
inner join country on countrysegments.country_id = country.id
inner join segments on countrysegments.segment_id = segments.id
所有我需要知道的是如何显示表的国家内的国家名称,
,各国家展所有段可用,没有什么与我的工作,如果有人可以帮助我将我很大的, 感谢ü
我尝试了很多没有答案,
我想个是:
select * from countrysegments inner join country on countrysegments.country_id = country.country inner join segments on countrysegments.segment_id = segments.segment
iknow IM远离正确的答案,但请谁能帮助?
COUNTRY_ID是id的国家表foregin关键 SEGMENT_ID是id的分段表的外键
我的数据库模式:
表名:countrysegments
id country_id segment_id
表名:国家
id country
表名:段
id segment
这是class.php:public function select(){ $stmt = $this->conn->prepare("SELECT country FROM
国家") or die($this->conn->error); if($stmt->execute()){ $result = $stmt->get_result(); return $result; } }
而这index.php`
<th class="text-center">country</th>
<th class="text-center">segments</th>
</thead>
<tbody>
<?php
require 'class.php';
$conn = new db_class();
$read = $conn->select();
while($fetch = $read->fetch_array(MYSQLI_ASSOC)){
foreach($fetch as $field=>$value){
echo '<tr><td>' . $value . '</td>';
}
}
?>
</tbody>
</table>`
这种解决方案我只有查询向我展示这些国家,但我需要在每个国家/地区使用下拉菜单展示所有细分受众群
请我需要你的帮助,所有
在DB中显示表 –
段有:id段国家有:id国家@BilalAhmed –
显示表结构。并且示例输出 –