I need to save the array $solution into the SQL table only if $solution[$i][0] belongs to the result of the query SELECT num_arr FROM Schedule WHERE num_arr<>''. If it does not belong to it, then the row $i must be not saved in the SQL table. The below-provided query seems to be incorrect. How do I implement the described task? What would be the correct approach to do this?
$query_land = "INSERT INTO `Sequence` (`num_arr`,`start`,`fin`,`way_id`)
VALUES ('".$solution[$i][0]."','".$solution[$i][1]."',
'".$solution[$i][2]."','".$solution[$i][3]."')
WHERE '".$solution[$i][0]."' IN (SELECT num_arr
FROM Schedule
WHERE num_arr<>'')";
The
INSERTstatment has two variations:and
The
dualis a system table with exactly 1 row. It can be used for various things. Here it’s used so aVALUES (...)is rewritten as aSELECT ...where we don’t have any suitable table to put in theFROMclause: