Re: [sqlite] Simple SQL question?

2017-11-15 Thread Bart Smissaert
o:sqlite-users- > >boun...@mailinglists.sqlite.org] On Behalf Of Bart Smissaert > >Sent: Wednesday, 15 November, 2017 15:05 > >To: SQLite mailing list > >Subject: Re: [sqlite] Simple SQL question? > > > >They end up in the wrong row. > > > >RBS > >

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Keith Medcalf
-users- >> >boun...@mailinglists.sqlite.org] On Behalf Of Bart Smissaert >> >Sent: Wednesday, 15 November, 2017 14:55 >> >To: SQLite mailing list >> >Subject: Re: [sqlite] Simple SQL question? >> > >> >That is getting close, but the cal

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Bart Smissaert
vember, 2017 14:55 > >To: SQLite mailing list > >Subject: Re: [sqlite] Simple SQL question? > > > >That is getting close, but the calculated values end up with the > >right ID, > >but the wrong ISSUE_DATE. > >Will if an order by can sort this out. > > >

Re: [sqlite] Simple SQL question?

2017-11-15 Thread petern
It is often helpful to study the syntax diagrams to see what is possible and intended by the language: https://sqlite.org/lang_update.html Take a look at the WHERE clause. The WHERE clause determines which rows are UPDATEd. One weakness in the documentation (although it may otherwise generally

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Keith Medcalf
-users [mailto:sqlite-users- >boun...@mailinglists.sqlite.org] On Behalf Of Bart Smissaert >Sent: Wednesday, 15 November, 2017 14:55 >To: SQLite mailing list >Subject: Re: [sqlite] Simple SQL question? > >That is getting close, but the calculated values end up with the >right ID

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Bart Smissaert
That is getting close, but the calculated values end up with the right ID, but the wrong ISSUE_DATE. Will if an order by can sort this out. RBS On Wed, Nov 15, 2017 at 9:33 PM, David Raymond wrote: > Try... > > UPDATE TABLE_A SET AGE_AT_ISSUE = > (SELECT

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Keith Medcalf
UPDATE table_a SET issue_date = (SELECT GetAgeAtDate(dob, issue_date) FROM table_p WHERE table_p.id = id); --- The fact that there's a Highway to Hell but only a Stairway to Heaven says a lot about anticipated traffic volume. >-Original

Re: [sqlite] Simple SQL question?

2017-11-15 Thread David Raymond
Try... UPDATE TABLE_A SET AGE_AT_ISSUE = (SELECT GetAgeAtDate(P.DOB, ISSUE_DATE) FROM TABLE_P AS P WHERE P.ID = ID); -Original Message- From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On Behalf Of Bart Smissaert Sent: Wednesday, November 15, 2017 4:17 PM To:

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Bart Smissaert
I like to just update that table as this AGE_AT_ISSUE column will be used often in various statements. There must be a simple way to do this, but just can't figure it out. RBS On Wed, Nov 15, 2017 at 9:25 PM, Peter Da Silva < peter.dasi...@flightaware.com> wrote: > Wouldn’t you create a view

Re: [sqlite] Simple SQL question?

2017-11-15 Thread Peter Da Silva
Wouldn’t you create a view instead, and not bother calculating age_at_issue until necessary since it’s derived completely from two other columns? On 11/15/17, 3:16 PM, "sqlite-users on behalf of Bart Smissaert"

Re: [sqlite] Simple SQL question?

2010-11-17 Thread Bart Smissaert
Tried your SQL, but it doesn't run. Will fiddle it and see if I can make it work. RBS On Wed, Nov 17, 2010 at 9:00 AM, luuk34 wrote: > On 17-11-10 09:58, Bart Smissaert wrote: >> What do you suggest should be the full SQL then? >> > select  t1.patient_id > from    table1 t1 >

Re: [sqlite] Simple SQL question?

2010-11-17 Thread luuk34
On 17-11-10 10:00, luuk34 wrote: > On 17-11-10 09:58, Bart Smissaert wrote: >> What do you suggest should be the full SQL then? >> > select t1.patient_id > fromtable1 t1 > join( > select table1.address, > min( table1.date_of_birth ) as

Re: [sqlite] Simple SQL question?

2010-11-17 Thread luuk34
On 17-11-10 09:58, Bart Smissaert wrote: > What do you suggest should be the full SQL then? > select t1.patient_id fromtable1 t1 join( select table1.address, min( table1.date_of_birth ) as date_of_birth fromtable1

Re: [sqlite] Simple SQL question?

2010-11-17 Thread Bart Smissaert
What do you suggest should be the full SQL then? RBS On Wed, Nov 17, 2010 at 8:16 AM, luuk34 wrote: > On 17-11-10 00:17, Petite Abeille wrote: >> select  t1.patient_id >> from    table1 t1 >> join    ( >>              select      table1.address, >>                          

Re: [sqlite] Simple SQL question?

2010-11-17 Thread Bart Smissaert
Tried your SQL, but it doesn't look right and didn't run. Will see if I can alter it. RBS On Tue, Nov 16, 2010 at 11:17 PM, Petite Abeille wrote: > > On Nov 16, 2010, at 11:55 PM, Bart Smissaert wrote: > >> This seems to work fine, > > Then you are golden :) > >> but

Re: [sqlite] Simple SQL question?

2010-11-17 Thread Bart Smissaert
That is a strange construction and for now I haven't got it to work yet in my VB application. It does run though in Firefox SQLite manager. Maybe after all the SQL I came up with in the end wasn't that bad. RBS On Wed, Nov 17, 2010 at 12:09 AM, Igor Tandetnik wrote: > Bart

Re: [sqlite] Simple SQL question?

2010-11-17 Thread luuk34
On 17-11-10 00:17, Petite Abeille wrote: > select t1.patient_id > fromtable1 t1 > join( > select table1.address, > min( table1.date_of_birth ) as date_of_birth > fromtable1 > group bytable1.address >

Re: [sqlite] Simple SQL question?

2010-11-16 Thread Igor Tandetnik
Bart Smissaert wrote: > Have (simplified) a table like this: > > CREATE TABLE TABLE1( > [PATIENT_ID] INTEGER PRIMARY KEY, > [ADDRESS] TEXT, > [DATE_OF_BIRTH] TEXT) > > DATE_OF_BIRTH is in the

Re: [sqlite] Simple SQL question?

2010-11-16 Thread Petite Abeille
On Nov 16, 2010, at 11:55 PM, Bart Smissaert wrote: > This seems to work fine, Then you are golden :) > but I am not sure if this SQL is correct and > if the results will always be correct and have a feeling > that there must be a better construction. > Any suggestions? Nothing very