mysql数据库多对多表关联
$link = mysqli_connect('localhost','root','root');
mysqli_select_db($link,'数据库名');
$res = mysqli_query($link,'set names utf8');
$sql = "SELECT
主表.name,副表1.teacher,副表2.name as uname
FROM
主表
INNER JOIN
副表1
ON
主表.teachar_id = 副表1.id
INNER JOIN
副表2
ON
主表.info_id = 副表2.id
";
$res = mysqli_query($link,$sql);
while ($arr = mysqli_fetch_assoc($res)){
print_r($arr);echo "<br>";
}
//
//主表作为中间表添加teacher_id和info_id与副表id对应