Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread John Machin
On 3/07/2009 7:08 AM, Ed Hawke wrote: > > Out of interest, would I be able to use binding on the run-time defined > fields? > > If I wanted to use: > > select * from A > join B b1 on (A.Column3 = b1.ID) > join C c1 on (b1.Column1 = c1.ID) > join D d1 on (b1.Column2 = d1.ID) > >

Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread Swithun Crowe
Hello EH Do the "a2-style" (for want of a better way of defining them) names EH exist outside the SQL statement which defines them? Tables and columns have fixed names, which you define when you write your database schema, e.g. CREATE TABLE myTable (id INT, value TEXT); But you can give

Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread Igor Tandetnik
Ed Hawke wrote: > Fine. > > Do the "a2-style" (for want of a better way of defining them) names > exist outside the SQL statement which defines them? Why does it matter? > i.e. if I execute the example statement that you gave me, then later > execute a statement which references c2 will that

Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread Ed Hawke
Fine. Do the "a2-style" (for want of a better way of defining them) names exist outside the SQL statement which defines them? i.e. if I execute the example statement that you gave me, then later execute a statement which references c2 will that work? Will other statements in the same

Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread Igor Tandetnik
Ed Hawke wrote: > All I meant was that in a database you have defined tables with > defined column names. These are defined before any SQL statements are > executed and therefore I would classify them as pre-defined. > > Contrast this with the "labels" applied to tables to create a separate >

Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread Ed Hawke
All I meant was that in a database you have defined tables with defined column names. These are defined before any SQL statements are executed and therefore I would classify them as pre-defined. Contrast this with the "labels" applied to tables to create a separate reference to them within an

Re: [sqlite] Nested Inner Join Help

2009-07-03 Thread Kees Nuyt
On Fri, 03 Jul 2009 00:53:12 +0100, Ed Hawke wrote: >Thank you again Igor. > >By run-time defined fields I meant column names that SQL would not >recognise until the query was executed, and therefore are only defined >when the statement is "run". I am

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Igor Tandetnik
Ed Hawke wrote: > By run-time defined fields I meant column names that SQL would not > recognise until the query was executed I don't get the distinction. Could you give an example of column names that SQL would somehow "recognize" before a query is executed? What do you mean by "recognize"

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Ed Hawke
Thank you again Igor. By run-time defined fields I meant column names that SQL would not recognise until the query was executed, and therefore are only defined when the statement is "run". I am aware that this is probably not the correct terminology. Ed Igor Tandetnik wrote: > Ed Hawke >

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Igor Tandetnik
Ed Hawke wrote: > Out of interest, would I be able to use binding on the run-time > defined fields? What's "run-time defined fields"? I'm not familiar with the term. > If I wanted to use: > > select * from A >join B b1 on (A.Column3 = b1.ID) >join

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Ed Hawke
Thank you very much for this Igor. Out of interest, would I be able to use binding on the run-time defined fields? If I wanted to use: select * from A join B b1 on (A.Column3 = b1.ID) join C c1 on (b1.Column1 = c1.ID) join D d1 on (b1.Column2 = d1.ID) join B b2 on (A.Column4 =

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Igor Tandetnik
Ed Hawke wrote: > To clarify this (I hope) if my table set-up is: > > Table A: > IDColumn1Column2Column3Column4 > 112345678921 23 > 216321587622 21 > 3

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Ed Hawke
Thank you both for your help. That works, but what happens if I want to do a more complex query. If Table B contains references to tables C and D then I can just extend your example to select information from D as well as C. However if I have multiple Columns in A that are occurrences of B.ID

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Adam DeVita
why not use: SELECT A.ID , A.Column1, A.Column2, B.Column1, C.Column1 FROM A INNER JOIN B ON A.Column3 = B.ID INNER JOIN C ON B.Column2 = C.ID ? On Thu, Jul 2, 2009 at 2:53 PM, Ed Hawke < edward.ha...@hawkeyeinnovations.co.uk> wrote: > Hi all, > >

Re: [sqlite] Nested Inner Join Help

2009-07-02 Thread Pavel Ivanov
I believe you need this: SELECT A.ID, A.Column1, A.Column2, B.Column1, C.Column1 FROM A INNER JOIN B ON A.Column3 = B.ID INNER JOIN C ON B.Column2 = C.ID Pavel On Thu, Jul 2, 2009 at 2:53 PM, Ed Hawke wrote: > Hi all, > > I'm having problems

[sqlite] Nested Inner Join Help

2009-07-02 Thread Ed Hawke
Hi all, I'm having problems getting nested inner joins to work with SQLite. As far as I can tell from various resources the correct way of joining multiple tables is this: SELECT A.ID, A.Column1, A.Column2, B.Column1, C.Column1 FROM A INNER JOIN B (INNER JOIN C ON B.Column2 = C.ID) ON