Il INSERT
istruzione ha due varianti:
INSERT INTO tableX
(a, b, c, ...)
VALUES
(1, 2, 3, ...) ;
e
INSERT INTO tableX
(a, b, c, ...)
SELECT
1, 2, 3
FROM
... ; --- the same or another table or many tables
Il dual
è una tabella di sistema con esattamente 1 riga. Può essere usato per varie cose. Qui viene utilizzato quindi un VALUES (...)
viene riscritto come SELECT ...
dove non abbiamo alcuna tabella adatta da inserire nel FROM
clausola:
$query_land = "INSERT INTO `Sequence` (`num_arr`,`start`,`fin`,`way_id`)
SELECT '".$solution[$i][0]."','".$solution[$i][1]."',
'".$solution[$i][2]."','".$solution[$i][3]."'
FROM dual
WHERE '".$solution[$i][0]."' IN (SELECT num_arr
FROM Schedule
WHERE num_arr<>'')";