如何从现有表创建新表,并将现有表的行作为新表的列。表

时间:2019-01-11 05:11:35

标签: php mysql

        $sql="SELECT qno FROM `cia1questions` ";
        $result = $mysqli ->query($sql);
        $counter = mysqli_num_rows($result);
        $createnew="CREATE table cia1markstest(
            Reg_no INT[12] primary key,
            st_name varchar[50] not null";
            $createnew1="";
        if($counter>0)
        {
            for($i = 0; $i < $counter; $i++){
                $row=$result->fetch_assoc();
                $createnew1.",".$row['qno']." INT[3]";

            } 
        }
        $createnew1.")";

        echo $createnew.$createnew1;
        $re=$mysqli->query($createnew.$createnew1);

这无法创建新表。我怎样才能解决这个问题?当我回显输出sql字符串时,仅正在读取createnew字符串。有人可以帮忙吗?

0 个答案:

没有答案