Am 27.06.2006 um 22:15 schrieb [EMAIL PROTECTED]:

My brain does not seem to be able to function properly today. I can think
of many ways to do what I want to do but none of them I like.

I will describe the problem in the most symplistic form.

I have two tables.  The first table, has a row which includes an 'id'
pointing to a row of another table.

create table config (profile_id integer, other_configs int );

The second table is defined as follows:

create table profile (id integer primary key autoincrement, name
varchar(32) unique, magic_number int);

Every entry in 'profile' should be unique. I would like to be able to
update (or insert if it does not exist) profile with a new 'magic_number' while keeping the same 'id' or updating the new 'id' in 'config' table.

What is the simplest way (and most efficient) to achieve this ?

Assuming you know the profile id, just use an INSERT OR REPLACE query (see <http://sqlite.org/lang_insert.htm>):

 INSERT OR REPLACE INTO profile VALUES(...)

Will insert a new record if none with that id exists or replace the data of the record with the given ID if it already exists.

HTH,
</jum>

Reply via email to