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 how would I create a statement to select the information from C and D for each of these?
To clarify this (I hope) if my table set-up is: Table A: ID Column1 Column2 Column3 Column4 1 12345 6789 21 23 2 16321 5876 22 21 3 31456 9108 22 24 Table B: ID Column1 Column2 21 31 42 22 31 41 23 33 43 24 32 41 Table C: ID Column1 31 Name1 32 Name2 33 Name3 Table D: ID Column1 41 Info1 42 Info2 43 Info3 How would I select A.ID, A.Column1, A.Column2, C.Column1, D.Column1, C.Column1, D.Column1 where the first set of info from C and D is based on the ID contained in A.Column3, and the second set on the ID in A.Column4? Sorry, I know this is massively more complicated, but that was why I was attempting to use nested Inner Joins, although I'm not necessarily sure they would have helped in this situation anyway. Regards, Ed Adam DeVita wrote: > why not use: > > SELECT A.ID <http://a.id/>, A.Column1, A.Column2, B.Column1, C.Column1 > FROM A > INNER JOIN B ON A.Column3 = B.ID <http://b.id/> > INNER JOIN C ON B.Column2 = C.ID <http://c.id/> > > ? > > On Thu, Jul 2, 2009 at 2:53 PM, Ed Hawke > <edward.ha...@hawkeyeinnovations.co.uk > <mailto:edward.ha...@hawkeyeinnovations.co.uk>> wrote: > > 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 <http://A.ID>, A.Column1, A.Column2, B.Column1, > C.Column1 FROM A INNER > JOIN B (INNER JOIN C ON B.Column2 = C.ID <http://C.ID>) ON > A.Column3 = B.ID <http://B.ID> > > However depending upon where I put the parentheses I get various > different errors from the viewer I use (SQLite Manager for Firefox). A > normal Inner Join without the nesting works fine. > > Can anyone tell me what I'm doing wrong? > > Regards, > > Ed > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org <mailto:sqlite-users@sqlite.org> > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > > > > > -- > VerifEye Technologies Inc. > 905-948-0015x245 > 7100 Warden Ave, Unit 3 > Markham ON, L3R 8B5 > Canada _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users