Skip to content
Advertisement

insert into a table from another table and add value from variable also in one SQL code

i am using INSERT INTO SELECT Statement Syntax to insert values from another table into my main table in my php project

It worked well but my issue is how to insert variable $student_id along with this on student_resulttbl. pls note $student_id is not coming from subjecttbl. Its set already. Thank you

Advertisement

Answer

If you want to INSERT $student_id to student_resulttbl table you should do query like this:

The summary code:

You can INSERT multiple columns with INSERT INTO command. More information there: w3schools.com/sql/sql_insert_into_select.asp or https://www.w3schools.com/sql/sql_insert.asp or https://www.dofactory.com/sql/insert

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement