I have 2 lists of postcodes, one origins and the other destinations:
I want to be able to import these to a mysql database so they are imported as single records for each journey. So the final results will be (where Origin and Destination are columns in the table):
firstOrigin firstDestination
firstOrigin secondDestination
firstOrigin thirdDestination
secondOrigin firstDestination
secondOrigin secondDestination
secondOrigin thirdDestination
thirdOrigin firstDestination
thirdOrigin secondDestination
thirdOrigin thirdDestination
Apologies if this is unclear. It's difficult to display a table on here!
Follow this question for importing data from CSV to mysql. You have to have two tables origins
and distinations
or better yet create temporary tables origins
and distinations
. Once you have imported data in mysql, You can get your result by applying cross product on both tables like this
INSERT INTO yourResultingTable
(origins, destinations)
SELECT origins.origin, destination.destination FROM origins, destinations;