0 Replies Latest reply on Feb 10, 2013 12:34 PM by Marcus Atkins

    Performing Left Join in Rhomobile

    Marcus Atkins

      Is it not possible to perform a left join in Rhomobile?

      I have models PriceGroups, PriceLookup which have a 1-many relationship (ie. each PriceGroup and have many PriceLookup records).

      I need to do a simple SQL Left Join so I have the required information from the PriceGroups Table

      SELECT * FROM PriceLookup LEFT JOIN PriceGroups ON PriceLookup.price_group_code=PriceGroups.code 

      I have added this to the price_lookup model:

        belongs_to :price_group_code, 'PriceGroups' 

      The following is what I have tried in Rhomobile

      PriceLookup.find_by_sql("SELECT * FROM PriceLookup LEFT JOIN PriceGroups on PriceLookup.price_group_code=PriceGroups.code") 

      But I get error:

      Error: could not prepare statement: 1; Message: no such table: PriceGroups 

      I know I can do two selects and join them myself but this is a very crap way of doing it