Subject Re: [ib-support] Re: Interbase DB Design Question...newbie zone.....
Author Thomas Miller
Join Table 1 to 2 and Table 2 to 3.

Or you can join Table 1 to 2 and table 1 to 3.

dbasch wrote:

>Martijn,
>OK, that makes sense to me. I have been programming SQL for a few
>months now. One last question that I was working up to. What if I
>have 3 tables. For instance, add an insurer table:
>
>#
>'t_insurer'
>pk_companyid
>companyname
>
>fk_company in 't_car' references pk_companyid
>#
>
>Now, how do I get the cars vin#, owners first and last name and the
>name of the insuring company. In other words, data from 3 tables.
>Thanks again,
>Derke T Basch
>
>
>
>
>--- In ib-support@y..., "Martijn Tonies" <m.tonies@u...> wrote:
>
>
>>Hi Derek,
>>
>>Read a book on SQL and look op the term JOIN.
>>
>>Here's a go at it:
>>
>>select car.make, owner.fname, owner.lname
>>from t_car car join t_owner owner on (car.fk_owner =
>>
>>
>owner.pk_ownerid)
>
>
>>With regards,
>>
>>Martijn Tonies
>>InterBase Workbench - the developer tool for InterBase and Firebird
>>http://www.interbaseworkbench.com
>>
>>Upscene Productions
>>http://www.upscene.com
>>
>>"This is an object-oriented system.
>>If we change anything, the users object."
>>
>>
>>
>>
>>>Hello Everyone,
>>>Ok here goes. I have 2 tables 't_car' and 't_owner'.
>>>#
>>>'t_car'
>>>pk_vin
>>>make
>>>fk_owner
>>>
>>>'t_owner'
>>>pk_ownerid
>>>fname
>>>lname
>>>
>>>fk_owner refrences pk_ownerid
>>>#
>>>
>>>Now, I query 'select * from t_car'. I get in return
>>>the car vin #, car make and the foreign key value of
>>>the car owner.
>>>I understand how to use the foriegn key referential
>>>contraint to refer to the 'pk_ownerid' in the owner
>>>table. What I dont understand is how to get the values
>>>associated with that foriegn key.
>>>(ex...'fname','lname').
>>>So, here is the question, how do I get a cars vin #
>>>and the associated owners first name and last name?
>>>Thanks for the help,
>>>Derek T Basch
>>>Portland OR
>>>
>>>
>>>
>>>
>>>
>>>__________________________________________________
>>>Do You Yahoo!?
>>>Yahoo! Finance - Get real-time stock quotes
>>>http://finance.yahoo.com
>>>
>>>
>>>To unsubscribe from this group, send an email to:
>>>ib-support-unsubscribe@e...
>>>
>>>
>>>
>>>Your use of Yahoo! Groups is subject to
>>>
>>>
>http://docs.yahoo.com/info/terms/
>
>
>>>
>>>
>
>
>
>To unsubscribe from this group, send an email to:
>ib-support-unsubscribe@egroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>
>
>

--
Thomas Miller
Delphi Client/Server Certified Developer
BSS Accounting & Distribution Software
BSS Enterprise Accounting FrameWork

http://www.bss-software.com




[Non-text portions of this message have been removed]