Home > Back-end >  Update the data in the database using excel doubt?
Update the data in the database using excel doubt?

Time:09-27

There is a refrigerator in SQL2000 database mydata, my_result need to manipulate the database tables, fields below
Id name result1 result2 result3
Zhang SAN 1

2, dick, and harry3 fifty
. .
N z


Result1 is the first result, result2 is the second time, result3 is third grade

Now I have a excel, only name and one result, equivalent to a three updates I have to get above the table of contents of complete,

Here's the thing, every time I excel the names of the corresponding order and the order as mentioned in the database table name is not the same, should how to operate?

CodePudding user response:

Write an UPDATE statement amount

To remove data in EXCEL

Then update to SQL
SQLSTR:='update mydata set result2=% f the where name=', '% s' "';



CodePudding user response:

reference 1st floor yangb0803 response:
write UPDATE statement amount

To remove data in EXCEL

Then update to SQL
SQLSTR:='update mydata set result2=% f the where name=', '% s' "';
actually don't need to entanglements order is right, it automatically to match?

CodePudding user response:

refer to the second floor gangrenxie response:
actually don't need to entanglements order is right, it automatically to match?


If with my such statement, don't tube order, where to find the record update is good, but the update data, more will be slow,
Need to use a progress bar display interface,


CodePudding user response:

Use conditional statement execution, database themselves function to do to operation,

CodePudding user response:

1, database using three temporary tables stored three grades,
2, use the group by query statements, specific help you see
3, the query results into my_result

CodePudding user response:

Give a thought:

Repeat//reading data from the EXCEL
Name=?
Result=?
Open the table
While not Eof the do//table cycle
Find the name on the same line
If result1='join
If result2="join
If result3="join
Next
The end;
Until no data

CodePudding user response:

Dynamically generated field name is ok, but also have to manage the new three times
SQLSTR=format (' update mydata set=% f the where name='% s' % s'' ', [resultfieldname resultfieldvalue, studentname]);
  • Related