php - How to add information to a specific column in a pre-existing database -


I have a database called "code> week1 that contains columns: age, address, polling Center, voter history, status, gender, border, county, and zip5 .

All the rows except the voter history are already in the table!

I need to import the voterhistory column from text file by name in the table named Vahist where Voternum is equal to vhist text file's voternum of the week's table.

The text file can insert several rows voter history column and must be separated by a comma

For example:

There is a person with voternum = 1234 within 1 week. In the vhist text file there are 3 records where voternum = 1234 .

is a voter history = 2011 , a voter history = 2012 , and a voter history = 2013 is < / p>

This means that when importing the vahist text file, those 3 records should be imported into the Voter History column of Week 1 table so that: 2011, 2012, 2013 .

Sorry if it seems misleading, but this is the only way I know how to explain it. If you need more information please let me know

In MySQL we call a function, this basic Forms a string value by using a specified separator. Take a look at the link

I will use a floating table to load the vhist in memory. Then, to join table 1 week based on matches, update the temporary table and update Week 1. It exits from implementing conditional arguments in your SQL combinations.

In the code, something like this will appear, you may have to do a little bit to run it: create a temporary table VIPART (polling station VARCHAR (10) Voter history VARCHAR (10)); Load data in local INFILE '/path/vhist.txt' tab in VIHIFF; Update Week 1 SET Voter History = SELECT CONCAT_WS (SELECT ',', WaterHostrae WHERE week1-voterum = vhistory-voterum);

I did not run this code because I do not have your data

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -