0

We have following table where we are storing students details

enter image description here

We have another table where we wish to store the logs

enter image description here

Now I wish to know is there any way we can loop through first table and insert data into another table using just mysql? I know it is very easy to write a simple script, but I need only mysql solution!

Transformation Rules

  1. Shaun and mark are missing in table 2 because they were absent on the day of exam
  2. For table 2, log would be Rob scored 3.2 marks not Rob scored 3.2 it was a type
  • 2
    What have you tried so far? Where are you stuck? Is there any rule behind the transformation? For example, why is Shaun not listed in the expected output? Why do the logs for Adam and Bill end in the string `marks`, but the log for Rob does not? – Nico Haase Nov 11 '21 at 09:02
  • Hi, since i've no knowledge of this! that is why i've done nothing till now! Shaun is omitted for being absent on the day of exam, rob log does end with marks, only thing i forgot to add that (type) – Missing Semicolon Nov 11 '21 at 09:05
  • Seems to me the `log` should be written at the same time as the marks are allocated. Then the date woudl also be correct, unlike now when I assume it will be some arbitrary hard coded date or now() – RiggsFolly Nov 11 '21 at 09:06
  • where is the date on first table ? – Ali Fidanli Nov 11 '21 at 09:06
  • See https://stackoverflow.com/questions/25969/insert-into-values-select-from – Azamat Abdullaev Nov 11 '21 at 09:07
  • How did you determine that Shaun is absent? The given data does not contain any such information. Also, what's about Mark? – Nico Haase Nov 11 '21 at 09:09

0 Answers0