better sql would be:
SELECT cb.brandName, ct.typeName, c.carPrice
FROM carsBrand AS cb
join carsType AS ct on ct.brandTypeIP=cb.id
join cars AS c on c.carTypeID=ct.id
SQLObject can represent this (with different sql) as either:
carlist = cars.select()
for car in carlist:
print car.price, car.type.name, car.type.brand.name
or
brandlist = carBrands.select()
for brand in brandlist:
for type in typelist:
for car in carlist:
print car.price, type.name, brand.name
On 3/22/07, Mauricio Tellez <[EMAIL PROTECTED]> wrote:
> Hi, I have the next classes:
>
> class cars(SQLObject):
> carPrice = IntCol(notNone=True)
> ... # some columns here
> carType = ForeignKey('carsType')
>
> class carsType(SLQObject):
> typeName = StringCol(length=64, notNone=True)
> ... # another columns here
> brandsCar = ForeignKey('brandsCar')
> cars = MultipleJoin('cars')
>
> class brandsCars(SQLObject):
> brandName = StringCol(lenght=32, notNone=True)
> ... # more columns here
> carsType = MultipleJoin('carsType)
>
> and each table has the following data:
>
> cars
> id carPrice ... carType
> 1 12000 1
> 2 25000 2
> 3 20000 3
>
> carsType
> id typeName ... brandsCar
> 1 Mustang 1
> 2 Eco Sport 1
> 3 Jetta 2
>
> carsBrand
> id brandName ...
> 1 Ford
> 2 VW
>
> and I want to get:
> Brand Type Price ...
> Ford Mustang 12000
> Ford Eco Sport 25000
> VW Jetta 20000
>
> the sql code to get this could be:
> SELECT t1.brandName, t2.typeName, t3.carPrice
> FROM carsBrand AS t1, carsType AS t2, cars AS T3
> WHERE t3.carTypeID=t2.id AND t2.brandTypeIP=t1.id
>
> how can I do that in SQLObject? Thanks for the help.
>
> --
> Mauricio
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> _______________________________________________
> sqlobject-discuss mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss
>
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss