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!
Try this :
INSERT INTO global_table (origin, destination)
SELECT origin_column, destination_column
FROM origin, destination
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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.