idontknowphp Posted August 24, 2011 Share Posted August 24, 2011 What is the best way to insert a large amount of data? I am talking like 1000+pages of text... i know insert is a starting point, I figured since it is for search purposes i can remove all the special characters and insert it. which brings up another (related) question... Say i want to insert into only certain columns that have a volume number of say 29...how would i build my query? I am assuming i need to use an insert and select together but i cant quite figure it out. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/ Share on other sites More sharing options...
fenway Posted August 24, 2011 Share Posted August 24, 2011 LOAD DATA INFILE works well. Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261142 Share on other sites More sharing options...
idontknowphp Posted August 24, 2011 Author Share Posted August 24, 2011 Thanks so much, I will work on figuring it out! I am a noob so i never even heard of that before... edit: Ok so i think that this will work well: LOAD DATA INFILE 'thefile.txt' INTO TABLE the_table (col1); But how can i structure it to only load into only those rows where there is a certain criteria, e.g. "only insert into col1 if col2=20" Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261151 Share on other sites More sharing options...
idontknowphp Posted August 24, 2011 Author Share Posted August 24, 2011 not trying to bump, updating progress....i sat down and did some pseudo code brainstorming...i think this might work and i cant believe it didn't occur to me earlier...but is there an easier way? Here is the pseudo code i came up with If the value of 'col2' is equal to '20' LOAD DATA INFILE 'thefile.txt' INTO TABLE the_table (col1) else Do nothing in other words, could a simple if statement or even a while loop work for the application? i will be populating the DB with the same data in some instances is why i ask... Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261204 Share on other sites More sharing options...
fenway Posted August 24, 2011 Share Posted August 24, 2011 Just dump into a temporary table, and then you can use INSERT INTO.. SELECT WHERE... as usual. Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261396 Share on other sites More sharing options...
idontknowphp Posted August 24, 2011 Author Share Posted August 24, 2011 I'm afraid my skill level isn't really up to par to fully understand that, could you elaborate a little more for me? I will do some reading as well to try and figure it out... Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261517 Share on other sites More sharing options...
fenway Posted August 24, 2011 Share Posted August 24, 2011 Don't dump into the target table -- make one up. Then you can SELECT using whatever criteria you want, and then use an INSERT to transfer them over to the target table. Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261576 Share on other sites More sharing options...
idontknowphp Posted August 24, 2011 Author Share Posted August 24, 2011 ok, so make a new table and use it for test purposes? then when it is correct, transfer it over? Sorry, I must sound like an idiot to you, but i have only minimal time with the language so i know next to nothing, just really basic data accessing and so forth. Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261587 Share on other sites More sharing options...
fenway Posted August 25, 2011 Share Posted August 25, 2011 ok, so make a new table and use it for test purposes? then when it is correct, transfer it over? Sorry, I must sound like an idiot to you, but i have only minimal time with the language so i know next to nothing, just really basic data accessing and so forth. Yup, that's the right idea. Quote Link to comment https://forums.phpfreaks.com/topic/245540-simple-mysql-data-question-just-need-a-push-in-the-right-direction/#findComment-1261823 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.