首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >cfoutput内部cfoutput输出

cfoutput内部cfoutput输出
EN

Stack Overflow用户
提问于 2011-08-15 11:11:01
回答 1查看 415关注 0票数 0

我想要创建一个包含每个产品和价目表的产品列表的表,但问题是我不能连接两个查询,因为我希望将一个输出插入到另一个输出中,但是要这样做是不可能的,我知道我必须加入2个sql查询才能正常工作,而且每个产品都有4种价格,为了更清楚地显示,我按照我希望看到的方式做了一个屏幕截图:http://s44.radikal.ru/i106/1108/57/33380d0557f4.jpg,以下是查询:

产品查询:

代码语言:javascript
复制
<cfquery name="get_products" datasource="#dsn3#">   SELECT DISTINCT P.*,PS.MONEY,PS.PRICE   FROM PRODUCT P,PRICE_STANDART PS    WHERE       P.IS_SALES=1        AND P.IS_PURCHASE=1         AND P.IS_INTERNET=1         AND P.PRODUCT_ID=PS.PRODUCT_ID      AND PS.PURCHASESALES=1      AND PS.PRICESTANDART_STATUS=1       <cfif len(trim(attributes.product_cat)) and len(attributes.product_code)>           AND P.PRODUCT_CODE LIKE '#attributes.product_code#%'        </cfif>         <cfif isdefined('attributes.product_id') and len(attributes.product_id)>            AND P.PRODUCT_ID=#attributes.product_id#        </cfif>     ORDER BY PS.PRICE DESC </cfquery>

价格查询:

代码语言:javascript
复制
<cfquery name="get_prices" datasource="#dsn3#">
        SELECT PRICE, PRODUCT_ID FROM PRICE WHERE PRODUCT_ID = #PRODUCT_ID#
    </cfquery>

和表:

代码语言:javascript
复制
<table cellpadding="3" cellspacing="1" class="color-border" width="100%">
    <tr class="color-header">
        <td width="30" class="header_bold">No</td>
        <td><b>Ürün</b></td>
        <td class="header_bold" width="80">Liste fiyatı</td>
        <td class="header_bold" width="80">Bayı 1</td>
        <td class="header_bold" width="80">Bayı 2</td>
        <td class="header_bold" width="80">Bayı 3</td>
        <td class="header_bold" width="80">Bayı 4</td>
        <td class="header_bold" width="25">Para</td>
    </tr>
    <cfoutput query="get_products" startrow="#attributes.startrow#" maxrows="#attributes.maxrows#">
        <tr height="20" onMouseOver="this.className='color-light';" onMouseOut="this.className='color-row';" class="color-row">
            <td>#currentrow#</td>
            <td>#product_name#</td>
            <td>#tlformat(price,2)#</td>
            <td>#tlformat((price*0.5),2)#</td> <!---this is fixed price! --->
            <td>#tlformat((price*0.49),2)#</td> <!---this is fixed price! --->
            <td>#tlformat((price*0.475),2)#</td> <!---this is fixed price! --->
            <td>#tlformat((price*0.45),2)#</td> <!---this is fixed price! --->
            <td align="center">#MONEY#</td>
        </tr>
    </cfoutput>
</table>

解释说:“这是固定价格!”意思是我将它们插入并按我自己的方式计算,但它应该从我想要整合的价格表中改变,但我不能.谢谢大家的帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2011-08-15 12:21:50

您确实应该对以下查询进行连接:

代码语言:javascript
复制
<cfquery name="get_products" datasource="#dsn3#">   
SELECT DISTINCT P.*,PS.MONEY,PS.PRICE   
FROM PRODUCT P
JOIN PRICE_STANDART PS ON P.PRODUCT_ID = PS.PRODUCT_ID
JOIN PRICE PR ON P.PRODUCT_ID = PR.PRODUCT_ID  
WHERE       
P.IS_SALES=1        
AND P.IS_PURCHASE=1         
AND P.IS_INTERNET=1               
AND PS.PURCHASESALES=1      
AND PS.PRICESTANDART_STATUS=1       
<cfif len(trim(attributes.product_cat)) and len(attributes.product_code)>           
  AND P.PRODUCT_CODE LIKE '#attributes.product_code#%'        
</cfif>         
<cfif isdefined('attributes.product_id') and len(attributes.product_id)>            
   AND P.PRODUCT_ID=#attributes.product_id#        
</cfif>     
ORDER BY PS.PRICE DESC 
</cfquery>

如果价格表为每个产品返回多个价格,则可以使用“组”属性。有关这方面的更多信息,请在这里查看:http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-7ff6.html

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7064259

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档