我想创建一个新的表调用checkdownload并从两个表中获取数据,这是一个学生和下载表。
table student
--------------------------------------------------
| studentId | username | password | email | name |
--------------------------------------------------
table downlaod
------------------------------------
| ID| studentId | downloadId | Name |
------------------------------------
$sql2="select id from upload";
$result2=mysqli_query($con,$sql2);
while($rows2=mysqli_fetch_array($result2))
{
$id5=$rows2['id'];
$sql3 = "create table checkdownload(SELECT student.studentId, student.name, downlaod.downlaodId, downlaod.Name FROM student as student LEFT JOIN downlaod as downlaod ON student.studentId = downlaod.studentId WHERE downlaod.downlaodId =$id5)";
$result3=mysqli_query($con,$sql3);
}
答案 0 :(得分:0)
CREATE table checkdownload as (SELECT s.studentId, s.name, d.downlaodId, d.Name FROM student s LEFT JOIN downlaod d ON s.studentId = d.studentId WHERE d.downlaodId =$id5)
如果你的查询没问题,这将创建包含结构和所有值的表。如果您只想要没有值的结构,请在最后添加and 1=2