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 = b2.ID)
    join C c2 on (b2.Column1 = c2.ID)
    join D d2 on (b2.Column2 = d2.ID);
where d2.ID = ?

Would that work?

Regards,

Ed


Igor Tandetnik wrote:
> Ed Hawke
> <edward.ha...@hawkeyeinnovations.co.uk> wrote:
>   
>> 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?
>>     
>
> 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 = b2.ID)
>     join C c2 on (b2.Column1 = c2.ID)
>     join D d2 on (b2.Column2 = d2.ID);
>
> Igor Tandetnik 
>
>
>
> _______________________________________________
> 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

Reply via email to