htmlmultiple-insert

multiple insert data in one table


I have 120 student in 4 class A,B,C,D in student table : Id_student, Name, Class and I have a payment table: Id, Id_student, Class, Payment, Date_payment, Status How i asking how to insert All student in class A with status not_complete


Solution

  • INSERT INTO payment (Id_student, Class, Status)
    SELECT Id_student, Class, "not_complete" AS Status
    FROM student
    WHERE Class = "A";
    

    Refer this link for more information.