Hi Michael,

> I have a table with two columns, the first with a string and the  
> second with
> an integer.

> Given a set of input strings, I want to perform this operation  
> 50,000+ times

So maybe something like:

create table InputTable
(
          InputString text collate nocase
)
;

with 50,000+ rows such as:

insert into InputTable values ('Mickey');
insert into InputTable values ('Donald');
insert into InputTable values ('Mickey');
insert into InputTable values ('Goofy');
insert into InputTable values ('Minnie');

> preferably in a single transaction: "If the string doesn't exist in  
> the
> table, create a new row with the string in the first column and 1 in  
> the
> second column. If the string does exist in the table, increment the  
> second
> column by 1"

Here's one simple solution:

create table Summary
as
select InputString, count(*)
from InputTable
group by InputString
;

which gives:

Donald   1
Goofy    1
Mickey   2
Minnie   1

Tom
BareFeet

  --
Cheapest ADSL1 and ADSL2 in Australia:
http://www.tandb.com.au/broadband/?ml

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

Reply via email to