Re: [sqlite] Conditional table select

2007-05-09 Thread Dennis Cote
Vitali Lovich wrote: The solution I came up with is: SELECT coalesce( (SELECT field1 FROM tbl1 WHERE key = $key), (SELECT field1 FROM tbl2 WHERE key = $key), (SELECT field1 FROM tbl3 WHERE key = $key)) , field2 FROM tbl1 WHERE key = $key; However, if coalesce works the way I think it does,

Re: [sqlite] Conditional table select

2007-05-06 Thread Vitali Lovich
Dan Kennedy wrote: On Fri, 2007-05-04 at 18:22 -0400, Vitali Lovich wrote: Multiple tables contain a primary key KEY. If Table1 contains a matching KEY, then I want that row from Table1. Only if it isn't in Table1, then look in Table2 if it is there. If not in Table2 go on to Table3, etc

Re: [sqlite] Conditional table select

2007-05-04 Thread Dan Kennedy
On Fri, 2007-05-04 at 18:22 -0400, Vitali Lovich wrote: > Hi, > > I was wondering what would be the optimal way to select 1 matching row > from multiple tables. Here is the scenario. > > Multiple tables contain a primary key KEY. If Table1 contains a > matching KEY, then I want that row from

[sqlite] Conditional table select

2007-05-04 Thread Vitali Lovich
Hi, I was wondering what would be the optimal way to select 1 matching row from multiple tables. Here is the scenario. Multiple tables contain a primary key KEY. If Table1 contains a matching KEY, then I want that row from Table1. Only if it isn't in Table1, then look in Table2 if it is