Re: How to create JOIN query

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Thu Jun 17 2004 - 21:41:23 EDT

  • Next message: Andrus Adamchik: "Re: How to create JOIN query"

    BTW, I hope everybody noticed that with M7 you can create SQLTemplates
    in the Modeler, so there is no need to concatenate Strings in Java
    code, unless you have something truly dynamic. And even if you do, you
    can define a "static" part of the query in the model and use it as a
    template later by cloning it via "queryWithParameters()"

    Andrus

    On Jun 16, 2004, at 7:42 PM, Gary Jarrel wrote:

    > If it's of any help one of the SQLTemplates that I use is:
    >
    >
    > StringBuffer buffer = new StringBuffer();
    > buffer.append("SELECT ")
    > .append(" #result('component_id' 'int'),")
    > .append("#result('indexable_components_all_active.component_category'
    > 'String' 'component_category'),")
    > .append(" #result('other_code' 'String'),")
    > .append(" #result('description' 'String'),")
    > .append(" #result('cost_price' 'Double'),")
    > .append(" #result('image' 'String'),")
    > .append(" #result('comp_link' 'String'),")
    > .append(" #result('man_name' 'String'),")
    > .append(" #result('man_url' 'String'),")
    > .append(" #result('sub_component_category' 'String'),")
    > .append(" #result('man_part_number' 'String'),")
    > .append("
    > #result('cast(((floor(round(((indexable_components_all_active.cost_pric
    > e * (1 + markup.markup_percentage/100))),2)*100))/100) as
    > decimal(10,2))' 'Double' 'sell_price') ")
    > .append(" FROM   indexable_components_all_active, markup, client ")
    > .append(" WHERE  client.category_name = markup.category_name AND ")
    > .append(" markup.component_category =
    > indexable_components_all_active.component_category AND ")
    > .append(" client.client_id = $userID AND
    > indexable_components_all_active.component_id IN $componentIDList")
    > .append(" #if( $orderings )" ).append(" ORDER BY $orderings
    > ").append("#end");



    This archive was generated by hypermail 2.0.0 : Thu Jun 17 2004 - 21:41:31 EDT