问题描述:

I have a 2 databases

1.db_temporary

2.db_primary

in db_temporary I have a table which contain bunch of data that I want to keep without overwrite it but update it from imported MYSQL file

I dump db_primary and import backup to db_temporary with this command

D:\mysql4.0.27\bin\mysqldump.exe --add-drop-table db_primary tb_wantomodify > "backupfile.sql"

D:\mysql4.0.27\bin\mysql.exe db_temporary < "backupfile.sql"

I have tried This Solution yeah it not overwrited , but what I want is update (addition) recent field of db_temporary with new value of backup.

Technicaly similiar to update set curvalue=curvalue+ 'newvaluefrombackup' like

Is it possible todo this?

Thank You

网友答案:

Firstly you can put both of those tables in the same database. There's no reason to create two seperate files. Secondly what you want here is the SQL UPDATE command. First create a database object and set it to your database.

SQLiteDatabase dataBase = SQLiteDatabase.openDatabase(myPath,
            null, SQLiteDatabase.OPEN_READWRITE);
database.execSQL("UPDATE " +yourTableNameHere+ " SET " +theColumnYouWantToUpdate+ "='" +theNewValue+ "' WHERE " +theColumnNametoUpdate+ "='" +theNewValue+ "'");

This may seem confusing at first but what you need to understand is that SQL commands read as strings. This example assumes you're using String constants for your table data, as you should. The + sign before and after is a concatenation command. Make sure you add spaces. And don't forget the commas after the values you want checked. There's a pretty good SQL commands tutorial here: [http://www.1keydata.com/sql/sqlselect.html]

相关阅读:
Top