Thank you very much!

you told me how to do. but I missed the "... defined as  UNIQUE ...".

Actually my question is just solved by two step:

First - CREATE UNIQUE INDEX i_recdata ON rec_data (num, di, time1);

Second - INSERT OR REPLACE INTO rec_data (num, di, data, time1, time2,
format) VALUES (12, '1290', '732e4a390000', 8323000, 8323255, 22); 




Simon Slavin-2 wrote:
> 
> 
> On 3 Jun 2009, at 7:05am, liubin liu wrote:
> 
>> the first step is to tell if there is the data in the table.
>> if the answer is not, I want to insert a row of data into the table
>> if the answer is yes, I need to update the row of data acccording to  
>> the
>> data inputting from me.
> 
> INSERT OR REPLACE INTO table (columns) VALUES (values)
> 
> This will use the columns and indices you have already defined as  
> UNIQUE to decide whether it should INSERT a new row or REPLACE an  
> existing one.  So take care in creating UNIQUE columns or a UNIQUE  
> index that does what you want.
> 
> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-compose-the-sqlite---if-exists-%28select-...%29---update-...--else---insert-into...-tp23845882p23883819.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to