Re: [sqlite] Update value from either database table?

2008-02-05 Thread Stephen Oberholtzer
On Feb 4, 2008 1:56 PM, Gussimulator <[EMAIL PROTECTED]> wrote:
> I have a field I need to update given a condition, but I don't know wether 
> the condition occurs in table A or table B, how can I perform this query?
>
> I have 2 identical tables in design, but one contains system data and the 
> other one contains user data... On my update routine (in C) I have to 
> increase an INTEGER field from either table given a condition... The thing 
> is, the condition could be present on both tables... what should I do??
>
> Thanks!

I'm no database expert, but why not merge them with a single table, like this?

[[ create table MyTable (foo, bar, baz, user_data INTEGER) ]]

with user_data=0 for the "system" data, and user_data=1 for the "user" data.

Unique/Primary-key constraints can be kept unique by appending the
user_data column to the index (how well does SQLite perform with
regard to multi-column indices, btw?)


-- 
-- Stevie-O
Real programmers use COPY CON PROGRAM.EXE
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Update value from either database table?

2008-02-04 Thread Gussimulator
table a: dict_base
table b: dict_user
condition: wether 'sz_word' = 'X' increase the value of 'dw_uses' by 1

sz_word could be in either table, dw_uses must be updated on the pertinent 
table/s though.

Sorry for not being too clear :)

Thanks again


- Original Message - 
From: "Fowler, Jeff" <[EMAIL PROTECTED]>
To: "General Discussion of SQLite Database" 
Sent: Monday, February 04, 2008 4:59 PM
Subject: Re: [sqlite] Update value from either database table?


> Without more info, here's the general approach:
>
> UPDATE c
> SET int_field = int_field+1
> WHERE (table a condition) OR (table b condition)
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Gussimulator
> Sent: Monday, February 04, 2008 1:57 PM
> To: sqlite-users@sqlite.org
> Subject: [sqlite] Update value from either database table?
>
> I have a field I need to update given a condition, but I don't know
> wether the condition occurs in table A or table B, how can I perform
> this query?
>
> I have 2 identical tables in design, but one contains system data and
> the other one contains user data... On my update routine (in C) I have
> to increase an INTEGER field from either table given a condition... The
> thing is, the condition could be present on both tables... what should I
> do??
>
> Thanks!
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users 

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


Re: [sqlite] Update value from either database table?

2008-02-04 Thread Igor Tandetnik
Gussimulator <[EMAIL PROTECTED]>
wrote:
> I have a field I need to update given a condition, but I don't know
> wether the condition occurs in table A or table B, how can I perform
> this query?
>
> I have 2 identical tables in design, but one contains system data and
> the other one contains user data... On my update routine (in C) I
> have to increase an INTEGER field from either table given a
> condition... The thing is, the condition could be present on both
> tables... what should I do??

When the condition holds in both tables, which one are you supposed to 
update? Do you need to update both? You could do the latter simply by 
running two almost-identical UPDATE statements, one against each table.

Igor Tandetnik 



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


Re: [sqlite] Update value from either database table?

2008-02-04 Thread Fowler, Jeff
Without more info, here's the general approach:

UPDATE c
SET int_field = int_field+1
WHERE (table a condition) OR (table b condition)

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Gussimulator
Sent: Monday, February 04, 2008 1:57 PM
To: sqlite-users@sqlite.org
Subject: [sqlite] Update value from either database table?

I have a field I need to update given a condition, but I don't know
wether the condition occurs in table A or table B, how can I perform
this query?

I have 2 identical tables in design, but one contains system data and
the other one contains user data... On my update routine (in C) I have
to increase an INTEGER field from either table given a condition... The
thing is, the condition could be present on both tables... what should I
do??

Thanks!

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


[sqlite] Update value from either database table?

2008-02-04 Thread Gussimulator
I have a field I need to update given a condition, but I don't know wether the 
condition occurs in table A or table B, how can I perform this query?

I have 2 identical tables in design, but one contains system data and the other 
one contains user data... On my update routine (in C) I have to increase an 
INTEGER field from either table given a condition... The thing is, the 
condition could be present on both tables... what should I do??

Thanks!

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